User Guide
296 Chapter 12: Working with External Media
To play back an external MPEG Layer 3 (MP3) file, use the loadSound() method of the Sound
class. This method lets you specify whether the MP3 file should progressively download or finish
downloading completely before it starts to play. You can also read the ID3 information embedded
in MP3 files, if they’re available. For more information, see “Reading ID3 tags in MP3 files”
on page 298.
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 299.
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 300.
Loading external SWF and JPEG files
To load a SWF or JPEG file, use the loadMovie() or loadMovieNum() global function, the
loadMovie() method of the MovieClip class, or the loadClip() method of the
MovieClipLoader class. For more information on the
loadClip() method, see
MovieClipLoader.loadClip() in Flash ActionScript Language Reference
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 might 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:
loadMovie("contents.swf", target_mc);
You can use MovieClip.loadMovie() to achieve the same result:
target_mc.loadMovie("contents.swf");