Good, 'cause my AS2 skills are rusty :)
First thing you'll want to do is go into the Library and create a class for all movie clips that you want to load.
Here's a screenshot of what it should look like:
http://screencast.com/t/f1awsbWik
Next, you'll want to put the following code on your buttons:
import flash.events.MouseEvent;
import flash.display.MovieClip;
function clearContainer():void {
while(myContainerMC.numChildren > 0) {
myContainerMC.removeChildAt(0);
}
}
myButton.addEventListener(MouseEvent.CLICK, myButtonClick, false, 0, true);
function myButtonClick(e:MouseEvent):void {
// if the container is not empty (i.e. if you have previously
// loaded another MC), the container's contents will be cleared.
clearContainer();
// create a new instance of your movieclip
// and add it to the container
var myMC:MovieClip = new MyTestMC();
myContainerMC.addChild(myMC);
}
Kind regards,
Pieter
General notice: from now on, I would like to ask everyone to put [AS2] or [AS3] (corresponding to the version of actionscript you are using on your project) in front of their post titles when the question is actionscript related! Please help us help you faster. Thank you.