[ Team LiB ] |
Recipe 13.8 Performing Actions When a Sound Ends13.8.1 ProblemYou want to perform certain actions when a sound finishes playing. 13.8.2 SolutionDefine an onSoundComplete( ) method for the Sound object. 13.8.3 DiscussionThe Sound class has a built-in event that triggers the onSoundComplete( ) method for a Sound object when the sound finishes playing. This is a convenient place to perform actions when the sound ends. All you need to do is define the onSoundComplete( ) method and Flash will automatically invoke it at the correct time: mySound_sound.onSoundComplete = function ( ) { trace("The sound has finished playing."); }; The onSoundComplete( ) method is invoked only when the end of the sound is reached. It is not invoked when the sound is stopped by way of ActionScript. Also, onSoundComplete( ) is invoked only when the last loop completes, not each time the sound loops, when a sound's playback is looped. 13.8.4 See Also |
[ Team LiB ] |