I have a stage to which a complex animation is added, including one step in the process: addChild(bitmapxyz).
At the end of this animation, I need to give the viewer the option of closing it, removing the added items, in order to start and view other animations.
Tried without success:
Get an 1120 error.
Not sure how to clean up the stage for this animation? Or maybe there's a way to create a child of the primary stage to hold the animation, then remove this stage.child? If this could work, can someone point me to how to add a child to a stage that then can hold what currently is being added to the stage?
Any help appreciated.
You can create an instance of Sprite that can then hold all of the child objects that you want to put on the stage.
var stuffHolder:Sprite = new Sprite();
Then, when you want to remove everything, you can just remove the sprite. This will remove everything that it contains.
If you want to keep that Sprite around for some reason, then just move it off the visible area of the stage.
Thanks for this suggestion. Did some reading on it, so a good learning experience for me. And, a good thing to know about.
I ended up sorting it out another way. But it is finally working OK.
In the future you can assign an instance name to a clip and then access it like that. If you don't want to keep references around then this is an easy way to access it again.
var someObj:MovieClip = new SomeLibraryObject(); // create a new instance of something in your library
someObj.name = "myObject"; // assign that instance a name
addChild(someObj); // add it to the display list
You can now access that clip some time later using the getChildByName() method as long as you have access to the stage its on. For instance:
removeChild( getChildByName("myObject") );
Europe, Middle East and Africa