all groups > flash actionscript > october 2005 >
You're in the

flash actionscript

group:

How do I check to see if a sound is finished


How do I check to see if a sound is finished Mattnesss
10/14/2005 8:28:16 PM
flash actionscript: I have a number of sounds that I am wanting to play in a user customized
sequence. How do I check to see if one sound has finished playing before I
start the next sound playing? The sounds are all pre-loaded. I am using Flash
MX2004

Thanks,

-Matt
Re: How do I check to see if a sound is finished NSurveyor
10/14/2005 10:24:06 PM
All Sound objects have a onSoundComplete event, which can be used like so:

mySound.onSoundComplete = function(){
trace("mySound just finished playing the sound!");
}

Here's an idea to accomplish what you want.... store the user customized
sequence in an array, and then every time a sound finished it looks to the next
item in the array until finished.. ex:

seq_array = ["bang","pop","splat","thwap","kaboom"]; // you'll probably want
to create this dynamically..
mySound = new Sound(this);
mySound.index = -1;
mySound.onSoundComplete = function(){
if(++this.index < seq_array.length){
this.attachSound(seq_array[this.index]);
this.start(0);
}else{
trace('finished!');
}
}
AddThis Social Bookmark Button