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
.
Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT
Page 1: ...ActionScript Reference Guide...
Page 8: ...8 Contents...
Page 12: ......
Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Page 54: ...54 Chapter 2 ActionScript Basics...
Page 80: ...80 Chapter 3 Writing and Debugging Scripts...
Page 82: ......
Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Page 112: ......
Page 120: ...120 Chapter 6 Using the Built In Classes...
Page 176: ......
Page 192: ...192 Chapter 10 Working with External Data...
Page 202: ...202 Chapter 11 Working with External Media...
Page 204: ......
Page 782: ...782 Chapter 12 ActionScript Dictionary...
Page 793: ...Other keys 793 221 222 Key Key code...
Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Page 816: ...816 Index...