简体   繁体   English

flash as3 movieClip loader没有按数字顺序加载

[英]flash as3 movieClip loader doesn't load in numerical sequence

I am loading an array of movie clips and adding them to the stage with flash as3, but the problem is that the movie clips are added to the stage as soon as they finish loading, and not in order of there position in the array, so the order on screen appears messed up. 我正在加载一系列电影剪辑并将它们添加到舞台上使用flash as3,但问题是影片剪辑在加载完成后立即添加到舞台,而不是按照阵列中的位置顺序添加,所以屏幕上的顺序显得混乱。 How do I ensure that they are added to the stage in the same order that their references exist in the URL? 如何确保它们以与URL中引用相同的顺序添加到舞台中? Here is my code: 这是我的代码:

var currentLoaded:int = 0;

function loadThumbs(){
    for (var i in project_array){
        var thumbLoader:Loader = new Loader();
        thumbLoader.load(new URLRequest(project_array[i].project_thumb));
        thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
    }
}

function thumbLoaded(e:Event):void {
    project_array[currentLoaded].projectThumb.thumbHolder.addChild(e.target.content);
    admin.slideHolder.addChild(project_array[currentLoaded].projectThumb);
    currentLoaded++;
}

Assets might load faster than others, so something like this might help... 资产的加载速度可能比其他资产更快,所以这样的事情可能有助于...

  function thumbLoaded(e:Event):void {
      project_array[currentLoaded].projectThumb.thumbHolder.addChild(e.target.content);
      currentLoaded++;
      if(currentLoaded>=project_array.length){
        addAssetsToStage();
      }
    }

    function addAssetsToStage():void{
      for(var i:int=0;i<project_array.length;i++)
      {
        admin.slideHolder.addChild(project_array[i].projectThumb);
      }   
    }

Well I was just typing the same solution... to Load in some specific order, you have to make it recursive. 好吧,我只是键入相同的解决方案...以某个特定的顺序加载,你必须使它递归。 You may try the loadermax library from greensock. 您可以尝试使用greensock中的loadermax库。 Is rock solid, fast and lightweight. 坚如磐石,快速轻巧。 Besides that very easy to use and you can set the ammount of parallel loading treads. 除了非常容易使用,你可以设置平行加载踏板的数量。 you can find it here 你可以在这里找到它

Well, I suppose this works - but if anyone figures out a way to do this without waiting for each previous image to load before starting another load, please let me know! 好吧,我想这是有效的 - 但是如果有人想出办法做到这一点而不等待每个先前的图像在开始另一个加载之前加载,请告诉我!

    var currentLoaded:int = 0;

function loadThumbs(){
    if (currentLoaded < project_array.length){
        var thumbLoader:Loader = new Loader();
        thumbLoader.load(new URLRequest(project_array[currentLoaded].project_thumb));
        thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
    }
}

function thumbLoaded(e:Event):void {
    project_array[currentLoaded].projectThumb.thumbHolder.addChild(e.target.content);
    admin.slideHolder.addChild(project_array[currentLoaded].projectThumb);
    currentLoaded++;
    loadThumbs();
}

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

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