PDA

View Full Version : Swapping external swf on main stage



bluedamaged
April 21st, 2008, 09:06 AM
Hey guys. This is probably an easy problem for you as3 gurus. I left the Flash world years ago only to come back to it now.

I have a main stage. In the stage are buttons to load external .swfs A, B, C. These buttons work fine using as3 Loader class. A visitor has to manually click on a button after each external swf is played to play the next. I would like A to automatically load B when done... and B to load C.

What I tried to do is to put an action at the end of A telling it to go to root and load B. As we all know, _root is no longer available. I've tried many things I've read on this forum but has not helped. How would I go about doing this. Hope you guys understand my question. Thanks.

worthyashes
April 21st, 2008, 10:46 AM
I think what you could do is dispatch an event from the loaded swf at the end of it. The code is something like :-

var evntObject:Event = new Event("clipFinished");
this.dispatchEvent(evntObject);

And on the base swf you can add a listener to trigger when it receives the dispatched event.

(Assuming the loaded clip is called 'loadedClip')

loadedClip.addEventListener("clipFinished",clipFinishedHandler);

function clipFinishedHandler(evt:Event):void
{
//Code for loading next clip here
}