2010-05-19 58 views
0

我想顯示一些動態文本,並從xml中的php文件中讀取。在swf播放器中,我只設置了三個按鈕。兩個按鈕的文字和一個按鈕的圖像。這一切工作正常,但白色背景所覆蓋的SWF背景。這是正常的看法和一些這個代碼片斷ActionScript-3中的一個UILoader中的動態文本

普通視圖圖像http://outshinebd.com/sm/Flash/normal_view.png http://outshinebd.com/sm/Flash/normal_view.png

代碼:

btnItem.addEventListener(MouseEvent.CLICK, showItem); 
//btnItem.addEventListener(Event:event, showItem); 
function showItem(event:Event):void 
{ 
    imgLoader.alpha =0; 
    textLoader.alpha=0; 
    imgLoader3.alpha=0; 
    imgLoader4.alpha=0; 
    imgLoader5.alpha=0; 
    imgLoader2.alpha=0; 

    var itemLoader:URLLoader = new URLLoader(); 
    itemLoader.load(new URLRequest("http://localhost/sm/flash/productdata")); 
    itemLoader.addEventListener(Event.COMPLETE , onItemLoad); 
    function onItemLoad(e:Event):void 
    { 
    var myLoader:XML = new XML(e.target.data); 
    xmlList = myLoader.children(); 

    //this values array will hold all of the values we need to paginate 
    var values:Array = new Array(); 
    //defining the 'i' variable so we can use it multiple times in for loops 
    var i:int; 

    for(i = 0; i < xmlList.length(); i++){ 
    //textLoader.text = xmlList[i].elements("productname"); 
    values[i] = xmlList[i].elements("productname"); 

    } 

    //the current page we're on 
    var page:int = 1; 
    //the limit of values we need per page 
    var limit:int = 1; 
    //the current row that we're working on 
    var row:int = 0; 
    //The total pages that we have 
    var totalPages:int = Math.ceil(values.length/limit); 

    function createValues():void{ 
    //this will always limit the amount to the limit variable 
    //but, "i" will act as a marker for which part of the values 
    //array that we're going to use 
    for(i=(page-1)*limit;i<page*limit;i++){ 
    //checks if there actually is a value where "i" is 
    //otherwise we'll get some undefined movieclips 
    if(i < values.length){ 
     var newValue:UILoader = new UILoader(); 
     //sets the coordinates based on the row 
     newValue.x = 5; 
     newValue.y = 5+newValue.height*row; 
     //sets this guys value to the correct part of the array 
     textLoader.text = values[i]; 
     //changing this guys name so we can reference it later 
     newValue.name = 'value'+row; 
     //adds the mc to stage 
     addChild(newValue); 
     //move onto the next row 
     row ++; 
    } 
    } 
    //then we reset the rows so we can use the variable again 
    row=0; 
    } 
    //function to remove the mc's 
    function removeValues():void{ 
    //this loop will run once for each mc on stage 
    for(i=0;i<limit;i++){ 
    //get the object in the current row and kill it! 
    removeChild(getChildByName('value'+i)); 
    } 
    } 

    //next page and previous page functions 
    function prevPage(event:MouseEvent):void{ 
    //checking if the current page isn't too low 
    if(page > 1){ 
    //take away all of the objects so we can make new ones 
    removeValues(); 
    page --; 
    createValues(); 
    //then update the page text 
    //updateString(); 
    } 
    } 
    function nextPage(event:MouseEvent):void{ 
    //checking if the current page isn't too high 
    if(page < totalPages){ 
    removeValues(); 
    page ++; 
    createValues(); 
    //updateString(); 
    } 
    } 

    //then we place the movieclips onto the stage 
    createValues(); 
    //adding listeners to the buttons 
    btnPrev.addEventListener(MouseEvent.CLICK, prevPage); 
    btnNext.addEventListener(MouseEvent.CLICK, nextPage); 

    } 
} 

而且點擊點擊圖像http://outshinebd.com/sm/Flash/after_click.png http://outshinebd.com/sm/Flash/after_click.png

後的按鈕

後視圖

我在過去的兩天裏一直在堆疊。請給我一個解決方案。

回答

0

看來你使用的是input TextField或帶有邊框和背景的TextTield,剛剛關閉它們:

textLoader.border=textLoader.background=false;