Skip navigation
Currently Being Moderated

Cleaning up the stage

May 7, 2012 6:03 PM



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.



  • Currently Being Moderated
    May 8, 2012 5:05 AM   in reply to saratogacoach

    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.

    Mark as:
  • Currently Being Moderated
    May 8, 2012 10:25 AM   in reply to saratogacoach

    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 = "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") );

    Mark as:
  • Currently Being Moderated
    May 8, 2012 1:33 PM   in reply to saratogacoach has a lot of good video tutorials on a range of subjects. Take a peek. The display list is something you'll probably work with the most in anything you do in Flash.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points