EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - CHAPTER 11 Working with External Media

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
193
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 products 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
file:// protocol.
To load external SWF and JPEG files, you can use either the
loadMovie() or loadMovieNum()
function, or the MovieClip.loadMovie() method. When you load a SWF or JPEG file, you
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
loadSound() method of the Sound
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 theyre
available. For more information, see “Reading ID3 tags in MP3 files” on page 196.

Table of Contents

Related product manuals