Play and stop sounds on enter and exit frames - AS3
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Play and stop sounds on enter and exit frames - AS3

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    15

    Play and stop sounds on enter and exit frames - AS3

    Hi there,

    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();
    mySound.play();

    What do I need to add, to have the sound stop, when the playhead exits that frame.

    Any help is much appreciated.

    Thanks

  2. #2
    Junior Member
    Join Date
    Feb 2010
    Posts
    23
    load your sound into a SoundChannel object.

    soundChannel.stop();

    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.

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    15
    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

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    23
    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:

    nameOfSoundChannel.stop();

    to the function that exits the frame, otherwise the barest timeline-based solution I can think of is to just add

    nameOfSoundChannel.stop();

    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.

  5. #5
    Junior Member
    Join Date
    Jan 2010
    Posts
    15
    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....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com