Hi,
Why don't you just make your class the listener for the
MovieClipLoader and then implement the functions in your class?
class LoadChecker {
var mcLoader:MovieClipLoader;
function LoadChecker() {
mcLoader = new MovieClipLoader();
mcLoader.addListener(this);
}
function myLoader(str, mc) {
//...
mcLoader.loadClip(str, mc);
}
function onLoadInit(mc...) {
trace("loaded mc " + mc) ;
//...doStuff.
mcLoaded(mc);
}
function onLoadError(mc...) {
trace("oops, there was an error ");
//...carry on?
}
function mcLoaded(mc) {
//...
}
}
Put a trace in your onLoadInit function and also implement the
onLoadError function for the listener so you can see if they are called
- you can also stub out the other functions for MovieClipLoader
listeners and put traces in those to make sure it starts loading, etc.
HTH
Glen
ali drongo wrote:
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
--
Glen Pike
01736 759321
www.glenpike.co.uk <http://www.glenpike.co.uk>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders