Play and stop sounds on enter and exit frames - AS3
I would like to have a sound file play when the playhead reaches a frame and then stop when the playhead moves to another frame.
This is the code I currrently have in the frame to play my sound (sound_1) - works fine, no problems...
var mySound:Sound = new sound_1();
What do I need to add, to have the sound stop, when the playhead exits that frame.
Any help is much appreciated.
load your sound into a SoundChannel object.
it's also just generally a better idea to play sounds through SoundChannel than just as Sounds I think ... or maybe just if you want to transform them (EQ, etc) but anyway that should work for you.
Thanks, but what I am looking for is that code that will initiate the stop sound event when it exits the frame. There doesn't seem to be an "exitFrame" event in AS3
well what are you using to exit the frame? i'm assuming you have a stop() to stop it and mayble like a button or something that makes the swf play again in which case just add:
to the function that exits the frame, otherwise the barest timeline-based solution I can think of is to just add
on the frame after the frame you want to have the music stop playing on ...
if it's still not clear enough post your code and I'll be able to see what you need more clearly.
Thanks... think you second suggestion is probably the easiest. The problem is that there is a drop down menu on top of the movie, so depending on what the user selects, it could be any number of destination frames the playhead will go to, which is why I wanted the action to be the "exitFrame" frame event, meaning I would have to do it only once....
Click Here to Expand Forum to Full Width
Poll by Flashkit.com