Hiya, I've written a class that will load multiple SWFs and then call a
passed function when complete. My problem is that when all the movies have
downloaded the passed function won't fire. If anyone could help me figure
this that would be really helpful.Cheers,
Ali
//
// LoadChecker
// this class is passed am array and calls a function when all of the
objects in the array are loaded
//
// Created by Alistair Colling on 2008-01-30.
// Copyright FPP Design Ltd 2008. All rights reserved.
//
// pass mcs to load and start loading
import mc.*;
import mx.utils.Delegate;
class mc.LoadChecker {
private var allLoadedFn:Function;
public var itemsToLoad_ar:Array;
private var itemsLoaded:Array;
public function LoadChecker(a:Array, f:Function) {
trace("loadchecker! created:"+a.toString());
allLoadedFn = f;
itemsLoaded = new Array();
itemsToLoad_ar = a;
for (var i = 0; i<itemsToLoad_ar.length; i++) {
var arRef:Number = i;
var tempLoad:LoadObj = itemsToLoad_ar[arRef];
myLoader(tempLoad.targURL,tempLoad.targMC);
}
}
function myLoader(str, mc) {
trace("MY LOADER loading file:"+str+" mc:"+mc);
var loadListener:Object = new Object();
var tmpFun:Function = mcLoaded;
loadListener.onLoadInit = function(target_mc:MovieClip):Void {
tmpFun.apply(null, [target_mc]);
};
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(loadListener);
//create holder inside of movie clip
var holder:MovieClip = mc.createEmptyMovieClip("holder",
mc.getNextHighestDepth());
mcLoader.loadClip(str,holder);
}
function mcLoaded(mcl:MovieClip) {
trace("a movie is loaded:"+mcl);
itemsLoaded.push(mcl);
if(itemsLoaded.length==itemsToLoad_ar.length){
trace("all movies are now loaded");
allLoadedFn.apply(null);
}
}
}
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders