Copy link to clipboard
Copied
Hey guys!
I have a button on screen that I want to be able to tap and play an audio as many times as I want when on the screen. But after moving to the next frame I want to remove that previous audio buttons event listener. But I'm unable to do this.
This is my code:
Hi.
I've edited my answer because it was not what you want.
But now going to the point... The event listener for the sound is only re-added when the user revisits the frame in which the code is located. If you want to play the sound as many time as you want, don't remove the listener.
To remove the listener when the frame is left, place the remove event listener for the audio in the goBack and/or goNext functions.
Also, please keep in mind that Animate automatically creates a global play
...Copy link to clipboard
Copied
Hi.
I've edited my answer because it was not what you want.
But now going to the point... The event listener for the sound is only re-added when the user revisits the frame in which the code is located. If you want to play the sound as many time as you want, don't remove the listener.
To remove the listener when the frame is left, place the remove event listener for the audio in the goBack and/or goNext functions.
Also, please keep in mind that Animate automatically creates a global playSound method when at least one sound in the Library has a linkage name assigned. So you should give your function another name. One more thing is that the gotoAndStop call in you goBack function doesn't have an argument.
I hope it helps.
Regards,
JC
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more