简体   繁体   English

ActionScript-3中一个UILoader中的动态文本

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

I want to show some dynamic text and that is read from a php file within xml. 我想显示一些动态文本,该文本是从xml中的php文件读取的。 Here in swf player i just set three button. 在SWF播放器中,我只设置了三个按钮。 Two button for text and one button for images. 两个按钮用于文本,一个按钮用于图像。 This all are working fine but the swf background covered by the white background. 这些都工作正常,但白色背景覆盖的swf背景。 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 普通视图图像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 button 和单击按钮后的视图

after clicking image http://outshinebd.com/sm/Flash/after_click.png http://outshinebd.com/sm/Flash/after_click.png 点击图片后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. 请给我一个解决方案。

似乎您正在使用带有边框和背景的input TextFieldTextTield ,只需将其关闭即可:

textLoader.border=textLoader.background=false;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM