一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

as 3.0调用多图片loading 代码

时间:2022-07-02 17:01:48 编辑:袖梨 来源:一聚教程网

stop();
var sp:Sprite=new Sprite(),url_array:Array=[],title_array:Array=[],getUrl_array:Array=[];
addChild(sp);
//------------- 导入XML数据资料区 --------------------------------------
var XML_URL:String = "http://sxl001.xfyun.com/Images.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);
var xmlLong:uint;
function xmlLoaded(event:Event):void {
  var myXML:XML = XML(myLoader.data);
  xmlLong =myXML.image.child("image").length();
  for (var i:uint =0; i     url_array.push([myXML.image.image[i].@title,myXML.image.image[i].@url]);
  }
  var getUrlLong:uint =myXML.getUrl.child("getUrl").length();
  for (var j:uint =0; j     getUrl_array.push(myXML.getUrl.getUrl[j].@url);
  }
  event.target.removeEventListener("complete", xmlLoaded);
  init(xmlLong);
}
function init(long:uint) {
  for (var j:uint=0; j     var loader:Loader = new Loader();
    initLoad(loader,j);
  }
}
function initLoad(loader:Loader,i:uint) {
  var target:bg_mc=new bg_mc();
  target.x=140*i-(Math.floor(i/5)*700);
  target.y=183*Math.floor(i/5);
  target.i=i;
  sp.addChild(target);
  loader.load(new URLRequest(url_array[i][1]));
  loader.addEventListener(Event.INIT, initHandler);
  loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
  loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadComplete);
  function loadProgress(event:ProgressEvent):void {
    var percent:Number=Math.round(event.bytesLoaded/event.bytesTotal*10000)/100;
    target.title_txt.text=percent+" %";
    target.title_txt.mouseEnabled=false;
  }
  function loadComplete(event:Event):void {
    var loadBitmap:Loader=Loader(event.target.loader);
    var image:Bitmap=Bitmap(loadBitmap.content);
    image.;
    image.;
    target.addChild(image);
    target.mc.stop();
    loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,loadComplete);
    loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loadProgress);
  }
}

热门栏目