To load and unload SWF

Hello,

I am studying AS3 by myself, please bear with me if my explanation is not that clear.

It’s all about loading and unloading external swf’s.
My code is working perfectly though I just have some questions about load and unload issues.

I have three buttons on the stage and it should load its external SWF

homeButton_btn - home.swf
page1Button_btn - page1.swf
page2Button_btn - page2.swf

Each of the button should load it’s external SWF’s intro when click.
My problem is that I don’t know how to command the button to play the swf’s outro and then load the next swf everytime I click a button

Example:

When I click homeButton_btn, the external swf should load “home.swf” and then if I am going to click page1Button_btn, the outro of "home.swf’ should play and then once it reaches the end of it’s timeline, it should load “page1.swf”.

Same goes with page2Button_btn, whatever swf that is on the stage should play it’s outro first and then load “page2.swf”

My questions are:

  1. How can I control the external SWF to play it’s outro and then load the next SWF.

  2. What code should I put at the end of the external SWF’s timeline.

  3. Where do you think I should put the preloader? Is it better to put it at the external swf timeline? or on my main swf timeline?

  4. Does load and unload of external swf also work with movieclips? Like for example I will not use a external swfs, instead I will use movieclips to load and unload its content.

Thanks!!


My Actionscript 3.0 code

var pageContainer:Loader;
pageContainer = new Loader();
var nextMov:String;
addChild(pageContainer);

homeButton_btn.addEventListener(MouseEvent.CLICK,o nHomeButtonClick);
function onHomeButtonClick(pEvent:MouseEvent) {
nextMov = “home.swf”
pageContainer.load(new URLRequest(nextMov));

}

page1Button_btn.addEventListener(MouseEvent.CLICK, onPage1Click);
function onPage1Click(pEvent:MouseEvent) {
nextMov = “page1.swf”
pageContainer.load(new URLRequest(nextMov));

}

page2Button_btn.addEventListener(MouseEvent.CLICK, onPage2Click);
function onPage2Click(pEvent:MouseEvent) {
nextMov = “page2.swf”
pageContainer.load(new URLRequest(nextMov));

}