Search code examples
flashactionscript-3actionscriptloadermovieclip

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. How do I ensure that they are added to the stage in the same order that their references exist in the 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++;
}

Solution

  • 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. 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