Sound
1111
var my_sound:Sound = new Sound();
// if the sound loads, play it; if not, trace failure loading
my_sound.onLoad = function(success:Boolean) {
if (success) {
my_sound.start();
status_txt.text = "Sound loaded";
} else {
status_txt.text = "Sound failed";
}
};
// load the sound
my_sound.loadSound("song1.mp3", true);
The
MovieClip.getNextHighestDepth()
method used in this example requires Flash Player
7 or later. If your SWF file includes a version 2 component, use the version 2 components
DepthManager class instead of the
MovieClip.getNextHighestDepth()
method.
See also
loadSound (Sound.loadSound method)
onSoundComplete (Sound.onSoundComplete
handler)
onSoundComplete = function() {}
Invoked automatically when a sound finishes playing. You can use this handler to trigger
events in a SWF file when a sound finishes playing.
You must create a function that executes when this handler is invoked. You can use either an
anonymous function or a named function.
Availability:
ActionScript 1.0; Flash Player 6
Example
Usage 1: The following example uses an anonymous function:
var my_sound:Sound = new Sound();
my_sound.attachSound("mySoundID");
my_sound.onSoundComplete = function() {
trace("mySoundID completed");
};
my_sound.start();
Usage 2: The following example uses a named function:
function callback1() {
trace("mySoundID completed");
}
var my_sound:Sound = new Sound();
Summary of Contents for FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Page 1: ...ActionScript 2 0 Language Reference ...
Page 1352: ...1352 ActionScript classes ...