Sometimes movie clips need to be removed from the stage because they are no longer necessary, and you prefer that your computer has its virtual memory and resources back for other objects on the stage to function more efficiently. The method to use is the removeMovieClip() method. The removeMovieClip() MethodThe removeMovieClip() method is used to remove movie clips that have been created manually or with ActionScript. It has two basic layouts: myMovie.removeMovieClip(); //method removeMovieClip(myMovie); //function Both generic uses have myMovie either as a parameter or as the object the method is being called from. Both uses, when called, accomplish the same thingremoving myMovie from the stage. Here is an example of removing movie clips from the stage:
The preceding code creates an empty movie clip and then removes the square_mc movie clip we created manually. After that, it removes the test_mc movie clip we created with code, and finally it uses a trace action to check to see whether the test_mc movie clip is still available. Test the movie and you should see nothing on the stage, and the Output window should say undefined, showing there isn't a test_mc movie clip available anymore. So far in this chapter, we have covered how to create movie clips, manipulate movie clips, and remove movie clips. The final section will cover the Drawing API for movie clips. |