Skip to main content
Known Participant
November 25, 2009
Answered

Do something at the end of an audio file

  • November 25, 2009
  • 1 reply
  • 337 views

Hello,

Does anyone know how in AS3 to have a button become visible when an audio file that has been placed on a frame in the main stage has finished playing?  I have tried to search for any info on this and cannot find anything online.  Arg.....

Thanks in advance for any help.

thepopguy

This topic has been closed for replies.
Correct answer kglad

remove the sound from the timeline.

in your library right click your sound, tick export for actionscript and assign a class (say MP3).


you can then use:

var s:MP3=new MP3();

var sc:SoundChannel=s.play();

sc.addEventListener(Event.SOUND_COMPLETE,soundcompleteF);

function soundcompleteF(e:Event){

// do whatever.  your sound is complete

}

1 reply

kglad
Community Expert
Community Expert
November 25, 2009

use the sound and soundchannel classes to instantiate your sound.  you can then use the soundcomplete event of the soundchannel class.

TIm_GalesAuthor
Known Participant
November 25, 2009

Thanks for the info.  I am a bit new to this.  Can you show me the code I would need to do this or direct me to a place that shows how I can do it?

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
November 25, 2009

remove the sound from the timeline.

in your library right click your sound, tick export for actionscript and assign a class (say MP3).


you can then use:

var s:MP3=new MP3();

var sc:SoundChannel=s.play();

sc.addEventListener(Event.SOUND_COMPLETE,soundcompleteF);

function soundcompleteF(e:Event){

// do whatever.  your sound is complete

}