User Guide
Loading and unloading additional SWF files 207
The with statement takes a movie clip as a parameter. The object you specify is added to the end
of the current target path. All actions nested inside a
with statement are carried out inside the
new target path, or scope. For example, in the following script, the
with statement is passed the
object
donut.hole to change the properties of hole:
with (donut.hole){
_alpha = 20;
_xscale = 150;
_yscale = 150;
}
The script behaves as if the statements inside the with statement were called from the Timeline of
the
hole instance. The previous code is equivalent to the following example:
donut.hole._alpha = 20;
donut.hole._xscale = 150;
donut.hole._yscale = 150;
The previous code is also equivalent to the following example:
with (donut){
hole._alpha = 20;
hole._xscale = 150;
hole._yscale = 150;
}
Loading and unloading additional 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 the
MovieClipLoader class in Flash ActionScript Language
Reference.
You can also use
loadMovie() to send variables to a CGI script, which generates a SWF file as its
CGI output. For example, you might use this to load dynamic SWF or JPEG 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 will load. If you load a SWF file into a target, the
loaded SWF file inherits the properties of the targeted movie clip. After the movie is loaded, you
can change those properties.
The
unloadMovie() method removes a SWF file previously loaded by loadMovie(). Explicitly
unloading SWF files with
unloadMovie() ensures a smooth transition between SWF files and
can decrease the memory required by Flash Player. 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.