O'Reilly logo

ActionScript: The Definitive Guide by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Removing Clip Instances and Main Movies

We’ve learned 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 created an instance or a movie determines the technique we use to remove that instance or movie later. We can explicitly remove movies and instances using unloadMovie( ) and removeMovieClip( ). Additionally, we may evict a clip implicitly by loading, attaching, or duplicating 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 both as a global function and as a method:

unloadMovie(clipOrLevel);   // Global function
clipOrLevel.unloadMovie( );  // Method

In global function form, clipOrLevel is a string indicating the path to the clip or level to unload. And due to automatic value conversion, clipOrLevel may also be a movie clip reference (movie clips are converted to paths when used as strings). In method form, clipOrLevel must be a reference to a movie clip object. The exact behavior of unloadMovie( ) varies according to whether it is used on a level or an instance.

Using unloadMovie( ) with levels

When applied to a level in the document stack (e.g., _level0, _level1, _level2), unloadMovie( ) completely removes the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required