Great Preload Method! but

Hi All

In the past, I’ve been successfully able to load an external swf into my main movie and manipulate the external movie clips using code loaded in the main movie…I’ve needed help with that in the beginning and you all were very helpful…thank you!

However, the above methods I used no longer work with this new preload method I’m now using.

I got this code from Lee Brimlow (not sure If I’m allowed to put his web url here) and I love it because it so simple and clean, but, I’m having issues assign listeners and events to external movie clips with this new method.

var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("main.swf"));

function loop(e:ProgressEvent):void
{
	var perc:Number = e.bytesLoaded / e.bytesTotal;
	percent.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void
{
	removeChildAt(0);
	percent = null;
	addChild(l);
}
  

The way that this is set up is you have a parent swf (that contains the above code) that loads the external swf into itself.

I then cast the loader object as a movie clip (not part of original code)

var mcExternal:MovieClip;
mcExternal=l.content as MovieClip; 

The problem is that when I want to load another swf (i.e. nav.swf) to replace the one that I just loaded(main.swf), flash won’t let me assign events to the external swf’s movie clips…(i get null erros)even though I use a different function to serve as the event handler for the next swf…

For example, I could use another “done” (done2) function to serve as the event handler for the COMPLETE listener that loads “nav.swf”, and throw the event handlers and listeners that pertain to “nav.swf” in done2 to avoid null errors but that still won’t work.

Sorry, this is kinda wordy…any ideas?