The SOUND_COMPLETE event is not triggered when your sound finishes playing.
There are a few different reasons why this problem may occur, but here’s how it played out in my project:
When you’re listening for a SOUND_COMPLETE event, you work with two Classes: Sound and SoundChannel. The event listener goes on the SoundChannel instance:
var sound:Sound = new Sound("allYouNeedIsLove.mp3"); var soundChannel:SoundChannel = sound.play(); soundChannel.addEventListener(Event.SOUND_COMPLETE, soundIsFinished);
In my project, i rigged up a “Pause” button. When the player clicks “Pause”, i stop the sound and take note of the Sound’s position. When the player clicks “Pause” again, i unpause the game and tell the Sound to start playing where we left off.
But whenever you paused and unpaused the game, the SOUND_COMPLETE Event wouldn’t fire any more.
That’s because whenever you tell a Sound object to play, it returns a new SoundChannel instance. The old SoundChannel instance – the one with the event listener on it – is no longer relevant, so the event doesn’t fire. So to get this to work, when the player unpauses the game, you have to add the SOUND_COMPLETE event listener to the new SoundChannel instance that’s returned when you call Sound.play();
THANKS FOR BAILING ME OUT!
BIG thanks to user WearDark on the Kirupa forums for clearing this up, and for saving me from hours and hours of bug testing trying to figure out what was going on!