开发者

Check the cumulative status of onLoadInit in a for statement

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()?


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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜