About loaded SWF files and the root Timeline
The ActionScript property
file. If you load a SWF file into a movie clip in another SWF file, any references to
loaded SWF file resolve to the root Timeline in the host SWF file, not that of the loaded SWF
file. This can sometimes lead to unexpected behavior at runtime, for example, if the host SWF file
and the loaded SWF file both use
In Flash Player 7 and later, you can use the
made by a movie clip to resolve to its own Timeline, rather than to the Timeline of the
_root
SWF file that contains that movie clip. For more information, see
loaded SWF files" on page
About accessing data in loaded SWF files
One SWF file can load another SWF file from any location on the Internet. However, for one
SWF file to access data (variables, methods, and so forth) defined in the other SWF file, the two
files must originate from the same domain. In Flash Player 7 and later, cross-domain scripting is
prohibited unless the loaded SWF file specifies otherwise by calling
System.security.allowDomain()
For more information, see
System.security.allowDomain()
Loading external MP3 files
To load MP3 files at runtime, use the
Sound object:
var song_1_sound = new Sound();
You then use the new object to call
sounds are loaded completely before being played; streaming sounds are played as they are
downloaded. You can set the
event sound or a streaming sound. After you load an event sound, you must call the
method of the Sound class 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 beethoven.mp3:
var classical:Sound = new Sound();
classical.loadSound("http://server.com/mp3s/beethoven.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're downloading 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 has completely downloaded, use the
This event handler automatically receives a Boolean (
the file downloaded successfully.
specifies or returns a reference to the root Timeline of a SWF
_root
to specify a variable.
_root
MovieClip._lockroot
123.
.
"Flash Player security features" on page 188
in
Chapter 12, "ActionScript Dictionary," on page
loadSound()
loadSound()
isStreaming
parameter to
isStreaming
method of the Sound class. First, create a
to load an event or a streaming sound. Event
parameter of
loadSound()
start()
classical
, especially if you're loading large sound
true
isStreaming
Sound.onLoad
or
true
false
_root
property to force references to
"Specifying a root Timeline for
and
to specify a sound as an
start()
.
and then loads an
to
.
false
event handler.
) value that indicates whether
Loading external MP3 files
in the
205.
195
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?
Questions and answers