I want to make it when a button is hit it creates a child and then when the child is hit it deletes the child….this works but then when I click the button again the child doesn’t get created again.
How can I do this? Here is my code:
var bikeride:MovieClip = new ridingbike();
ridinb.addEventListener(MouseEvent.CLICK, openbike);
function openbike(evt:MouseEvent):void {
addChild(bikeride);
}
bikeride.addEventListener(MouseEvent.CLICK, closebike);
function closebike(evt:MouseEvent):void {
bikeride.removeChildAt(0);
}
You can remove the child using:
If you don’t store the
bikerideinstance you can do this: