It looks like your loadListener object goes out of scope as you only
declare it inside the function - try making it a class variable then
creating a new one for each movieclip that you want to load in. Same
with your tmpFun assignment and you may want to look at using Delegate
if this is still not working:
tmpFun = Delegate.create(this, mcLoaded);
Glen
Alistair Colling wrote:
Thanks for your quick reply Glen, thing is, I want to allow the class
to trigger different functions that are passed to it and also to
monitor the progress of a number of SWFs. Sorry if I'm missing
something here.
Cheers,
Ali
On 31 Jan 2008, at 10:55, Glen Pike wrote:
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
_______________________________________________
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