CHAPTER 11
Working with External Media
If you import an image or a sound while you author a document in Macromedia Flash MX 2004
or Macromedia Flash MX Professional 2004, the image and sound are packaged and stored in the
SWF file when you publish it. In addition to importing media while authoring, you can load
external media at runtime. There are several reasons you might want to keep media outside a
Flash document.
Reduce file size
By keeping large media files outside your Flash document and loading them at
runtime, you can reduce the initial download time for your applications and presentations,
especially over slow Internet connections.
Modularize large presentations
You can break up a large presentation or application into
separate SWF files and then load those separate files as needed at runtime. Not only does this
reduce initial download time, but it also makes maintaining and updating the contents of the
presentation easier.
Separate content from presentation
This a common theme in application development,
especially data-driven applications. For example, a shopping cart application might display a
JPEG image of each product. By loading the JPEG files for each image at runtime, you can easily
update a product's image without modifying the original FLA file.
Take advantage of runtime-only features
Some features, such as streaming FLV and MP3
playback, are only available at runtime through ActionScript.
Overview of loading external media
There are four types of media files that you can load into a Flash application at runtime: SWF,
MP3, JPEG, and FLV files. Flash Player can load external media from any HTTP or FTP address,
from a local disk using a relative path, or by using the
protocol.
file://
To load external SWF and JPEG files, you can use either the
or
loadMovie()
loadMovieNum()
function, or the
method. When you load a SWF or JPEG file, you
MovieClip.loadMovie()
specify a movie clip or movie level as the target for that media. For more information on loading
SWF and JPEG files, see
"Loading external SWF and JPEG files" on page
194.
To play back an external MP3 (MPEG Layer 3) file, use the
method of the Sound
loadSound()
class. This method lets you specify whether the MP3 file should stream or download 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
196.
193
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?