Replacing an instance on the stage with an instance from library
I have several instances (movieclips) in the library that will be placed on the stage when the user clicks the appropriate button.
My first thought was to create a container for the movieclips to load into:
var mcContainer: Sprite = new Sprite();
addChild(mcContainer);
This is the code for one of the buttons:
btnStep1.addEventListener(MouseEvent.CLICK, Step1);
function Step1(event: MouseEvent): void {
var Step1: Step1;
Step1 = new Step1();
mcContainer.addChild(Step1);
Step1.x = 238;
Step1.y = 167;
trace: ("Step1");
}
I was hoping that loading movieclip Step2 into the mcContainer would automatically remove Step1 movieclip.
The end user has the ability to click any one of 6 buttons so I could not use removeChild since it could be one of a possible 6 movieclips loaded.
What am trying to achieve to load an instance from the library with a mouse click and if the user clicks one of 5 other buttons, the corresponding instance loads and replaces the instance currently on the stage.
