A SERVICE OF

logo

Macromedia MAX 2005 - Anaheim, CA What’s New In Flash 8
109
Loading Graphics Dynamically
Loading GIF, PNG and Progressive JPEGs
To load a SWF or image 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 the ActionScript
2.0 Language Reference.
For image files, Flash Player 8 supports the JPEG (progressive and non-progressive) image
file type, GIF images (transparent and non-transparent, although only the first frame of an
animated GIF will be loaded), and PNG files (transparent and non-transparent).
To load a SWF or image file into a level in Flash Player, use the loadMovieNum() function. To load a
SWF or image 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 image file into a movie clip target, the upper-left corner of the SWF file or
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 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 SWF or image file according to data passed from the Flash application.
When you use the global loadMovie() or loadMovieNum() function, specify the target level or clip as
a parameter. The following example loads the Flash application contents.swf into the movie clip
instance named image_mc:
loadMovie("contents.swf", image_mc);
You can use MovieClip.loadMovie() to achieve the same result:
image_mc.loadMovie("contents.swf");
The following example loads the image1.jpg JPEG image into the image_mc movie clip instance:
image_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg");