About Loading And Using External Mp3 Files - MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

About loading and using external
MP3 files
To load MP3 files at runtime, use the
create a Sound object, as shown in the following example:
var song1_sound:Sound = new Sound();
Use the new object to call
are loaded completely before being played; streaming sounds play as they download. You can
set the
isStreaming
sound. After you load an event sound, you must call the
to make the sound play. Streaming sounds begin playing when sufficient data is loaded into
the SWF file; you don't need to use
For example, the following code creates a Sound object named
MP3 file named song1.mp3. Put the following ActionScript in Frame 1 on the Timeline:
var my_sound:Sound = new Sound();
my_sound.loadSound("http://www.helpexamples.com/flash/sound/song1.mp3",
true);
In most cases, set the
files that should start playing as soon as possible—for example, when creating an MP3
"jukebox" application. However, if you download shorter sound clips and need to play them
at a specified time (for example, when a user clicks a button), set
To determine when a sound IS completely downloaded, use the
handler. This event handler automatically receives a Boolean value (
indicates whether the file downloaded successfully.
For more information, see the following topics:
"Loading an MP3 file" on page 599
"Preloading MP3 files" on page 599
"Reading ID3 tags in MP3 files" on page 601
You can find a sample source file that loads MP3 files, jukebox.fla, in the Samples folder on
your hard disk. This sample demonstrates how to create a jukebox by using data types, general
coding principles, and several components:
In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\Components\Jukebox.
On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/Components/Jukebox.
598
Working with Images, Sound, and Video
loadSound()
to load an event or a streaming sound. Event sounds
loadSound()
parameter of
loadSound()
start()
parameter to
isStreaming
method of the Sound class. First, you
to specify a sound as a streaming or event
start()
.
my_sound
, especially if you're loading large sound
true
isStreaming
Sound.onLoad
method of the Sound class
and then loads an
to
false
event
or
) that
true
false
.

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents