194 Chapter 11: Working with External Media
Flash Video (FLV) is the native video format used by Flash Player. You can play back FLV files
over HTTP, or from the local file system. Playing external FLV files provides several advantages
over embedding video in a Flash document, such as better performance and memory
management, and independent video and Flash frame rates. For more information, see “Playing
back external FLV files dynamically” on page 197.
You can also preload, or track the download progress, of external media. Flash Player 7 introduces
the MovieClipLoader class, which you can use to track the download progress of SWF or JPEG
files. To preload MP3 and FLV files, you can use the
getBytesLoaded() method of the Sound
class and the
bytesLoaded property of the NetStream class. For more information, see
“Preloading external media” on page 198.
Loading external SWF and JPEG files
To load a SWF or JPEG file, use the loadMovie() or loadMovieNum() global function, or the
loadMovie() method of the MovieClip class. To load a SWF or JPEG file into a level in Flash
Player, use
loadMovieNum(). To load a SWF or JPEG file into a movie clip target, use the
loadMovie() function or method. In either case, the loaded content replaces the content of the
specified level or target movie clip.
When you load a SWF or JPEG file into a movie clip target, the upper left corner of the SWF file
or JPEG image is placed on the registration point of the movie clip. Because this registration
point is often the center of the movie clip, the loaded content may not appear centered. Also,
when you load a SWF file or JPEG image to a root Timeline, the upper left corner of the image is
placed on the upper left corner of the Stage. The loaded content inherits rotation and scaling
from the movie clip, but the original content of the movie clip is removed.
You can optionally send ActionScript variables with a
loadMovie() or loadMovieNum() call.
This is useful, for example, if the URL you’re specifying in the method call is a server-side script
that returns a JPEG or SWF file according to data passed from the Flash application.
For image files, Flash supports only the standard JPEG image file type, not progressive JPEG files.
When you use the global
loadMovie() or loadMovieNum() function, specify the target level or
clip as a parameter. For example, the following code loads the Flash application contents.swf into
the movie clip instance named
target_mc:
loadMovieNum("contents.swf", target_mc);
Equivalently, you can use MovieClip.loadMovie() to achieve the same result:
target_mc.loadMovie("contents.swf");
The following code loads the JPEG image flowers.jpg into the movie clip instance image_clip:
image_clip.loadMovie("flowers.jpg");
For more information about loadMovie(), loadMovieNum(), and MovieClip.loadMovie(), see
their entries in Chapter 12, “ActionScript Dictionary,” on page 205.