Onsoundcomplete (Sound.onsoundcomplete Handler) - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

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
method used in this example requires Flash Player
MovieClip.getNextHighestDepth()
7 or later. If your SWF file includes a version 2 component, use the version 2 components
DepthManager class instead of the
method.
MovieClip.getNextHighestDepth()
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();
Sound
1111

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

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

This manual is also suitable for:

Flash 8

Table of Contents

Save PDF