Share this Page URL

Chapter 13. Movie Clips > Removing Clip Instances and Main Movies - Pg. 358

controls clips based not only on their name but also on their location. For example, we might create a generic navigational button that, by examining its targetPath(), sets its own color to match the section of content within which it resides. See the example under the Selection object in the Language Reference for a demonstration of targetPath() in action. Removing Clip Instances and Main Movies We've seen how to create and refer to movie clips; now let's see how to turn them into so many recycled electrons (in other words, blow 'em away). The manner in which we create an instance or a movie determines the technique we use to remove that instance or movie later. We can remove movies and instances explicitly using unloadMovie() and removeMovieClip(). Additionally, we can evict a clip implicitly by using loadMovie(), attachMovie(), or duplicateMovieClip() to place a new clip in its stead. Let's look at these techniques individually. Using unloadMovie() with Instances and Levels The built-in unloadMovie() function can remove any clip instance or main movie-- both those created manually and those created via loadMovie(), duplicateMovieClip(), and attachMovie(). It can be invoked either as a global function or as a instance-level method: