开发者

Dynamic text within one UILoader in ActionScript-3

开发者 https://www.devze.com 2022-12-30 15:07 出处:网络
I want to show some dynamic text and that is read from a php file within xml. Here in swf player i just set three button. Two button for text and one button for images. This all are working fine but t

I want to show some dynamic text and that is read from a php file within xml. Here in swf player i just set three button. Two button for text and one button for images. This all are working fine but the swf background covered by the white background. Here is the normal view and some of this code snippet

normal view image http://outshinebd.com/sm/Flash/normal_view.png http://outshinebd.com/sm/Flash/normal_view.png

Code :

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);

  }
 }

And the view after clicking the bu开发者_JAVA百科tton

after clicking image http://outshinebd.com/sm/Flash/after_click.png http://outshinebd.com/sm/Flash/after_click.png

I'm stacked with in the last two days. Please give me a solution.


It seems that you are using an input TextField or a TextTield with a border and a background, just turn them off:

textLoader.border=textLoader.background=false;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号