Loading and unloading SWF files 355
Loading and unloading SWF files
To play additional SWF files without closing Flash Player, or to switch SWF files without
loading another HTML page, you can use one of the following options:
■ The global loadMovie() function or loadMovie() method of the MovieClip class.
■ The loadClip() method of the MovieClipLoader class. For more information on the
MovieClipLoader class, see
MovieClipLoader in the ActionScript 2.0 Language
Reference.
You can also use the
loadMovie() method to send variables to a CGI script, which generates
a SWF file as its CGI output. For example, you might use this procedure to load dynamic
SWF or image files based on specified variables within a movie clip. When you load a SWF
file, you can specify a level or movie clip target into which the SWF file loads. If you load a
SWF file into a target, the loaded SWF file inherits the properties of the targeted movie clip.
After the Flash movie is loaded, you can change those properties.
The
unloadMovie() method removes a SWF file previously loaded by the loadMovie()
method. Explicitly unloading SWF files with
unloadMovie() ensures a smooth transition
between SWF files and can decrease the memory that Flash Player requires. It can be more
efficient in some situations to set the movie clip’s
_visible property to false instead of
unloading the clip. If you might reuse the clip at a later time, set the
_visible property to
false and then set to true when necessary.
Use
loadMovie() to do any of the following:
■ Play a sequence of banner ads that are SWF files by placing a loadMovie() function in a
container SWF file that sequentially loads and unloads SWF banner files.
■ Develop a branching interface with links that lets the user select among several SWF files
that are used to display a site’s content.
■ Build a navigation interface with navigation controls in level 0 that loads content into
other levels. Loading content into levels helps produce smoother transitions between
pages of content than loading new HTML pages in a browser.
For more information on loading SWF files, see “Loading external SWF and image files”
on page 593.
For more information, see the following topics:
■ “Specifying a root timeline for loaded SWF files” on page 356
■ “Loading image files into movie clips” on page 357