Question : Run function when sound is complete

I have an MP3 loading / playing in my flash file (code below).

My question, how can I tell flash to do something (run function) when the file is completed playing...?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var soundReq:URLRequest = new URLRequest("path1_a.mp3");
var sound:Sound = new Sound();
sound.load(soundReq);
 
sound.addEventListener(Event.COMPLETE, onComplete);
 
function onComplete (event:Event):void
{
	sound.play();
}
Open in New Window Select All

Answer : Run function when sound is complete

Try the following:



-V
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var soundReq:URLRequest = new URLRequest("path1_a.mp3");
var sound:Sound = new Sound();
sound.load(soundReq);
 
sound.addEventListener(Event.COMPLETE, onComplete);
sound.addEventListener(Event.SOUND_COMPLETE, soundFinished);
 
function onComplete (event:Event):void {
	sound.play();
}
 
function soundFinished (event:Event):void {
	trace("my sound finished!");
}
Open in New Window Select All
Random Solutions  
 
programming4us programming4us