views:

22

answers:

1

In a setup like this is it possible to check the cumulative status of all onLoadInit?

for(var i:Number = 0; i < limit; i++) {
    var mcLoader:MovieClipLoader = new MovieClipLoader();
    var mclListener:Object = new Object();
    mclListener.onLoadInit = function(mc:MovieClip) {
        trace(i + " is finished loading!");
    }
    mcLoader.addListener(mclListener);
    mcLoader.loadClip(some_image_path, someMovieClip);
}

Initially I was thinking that I could pass an array of Boolean's, but I'm not really sure where to add that checkpoint, because a flash frame doesn't keep looping. Would I have to add it to an onEnterFrame()?

A: 

Wow, a simple counter suffices.

var sum:Number = 0;

for(var i:Number = 0; i < limit; i++) {
    var mcLoader:MovieClipLoader = new MovieClipLoader();
    var mclListener:Object = new Object();
    mclListener.onLoadInit = function(mc:MovieClip) {
        trace(i + " is finished loading!");
        sum++;
        if(sum >= limit) {
            trace("All onLoadInits have fired!");
        }
    }
    mcLoader.addListener(mclListener);
    mcLoader.loadClip(some_image_path, someMovieClip);
}
jonobr1