簡體   English   中英

ActionScript-3中一個UILoader中的動態文本

[英]Dynamic text within one UILoader in ActionScript-3

我想顯示一些動態文本,該文本是從xml中的php文件讀取的。 在SWF播放器中,我只設置了三個按鈕。 兩個按鈕用於文本,一個按鈕用於圖像。 這些都工作正常,但白色背景覆蓋的swf背景。 這是普通視圖和一些代碼片段

普通視圖圖像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

最近兩天我一直都在堆。 請給我一個解決方案。

似乎您正在使用帶有邊框和背景的input TextFieldTextTield ,只需將其關閉即可:

textLoader.border=textLoader.background=false;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM