Jump to content
Search Community

stopping sound

vdheyning test
Moderator Tag

Recommended Posts

Hi Jack,

 

thank you for your reply to my other topic, I'll have to re-create that situation to post an smaller FLA file, so you can see what I mean.

 

Now I have another issue, how do I stop sound with a mouse event?

 

See attached file, I want the sound to start playing (like in a button) on rollover, and then I want it to stop playing on roll out, but I can't get that to work, if the sound is short enough, like a click, it's no problem, but with a longer sound file, it wont work, it seems such a simple thing...

As always, thanks!

 

Fam

Link to comment
Share on other sites

There were several problems with our file:

 

1) You were loading the file every time your mouse rolled over your button. That's very wasteful and would explain why it took a while. You should only load it once and then play the sound each time.

 

2) You were calling pause() on the LoaderMax instance which simply paused the loading of the MP3. If it had already finished loading when pause() is called, it doesn't really do anything.

 

I have good news. I just added a BUNCH of capabilities to the MP3Loader class. Version 1.24 introduces playSound(), pauseSound(), and gotoSoundTime() methods as well as volume, soundPaused, soundTime, and playProgress properties. It dispatches new SOUND_COMPLETE, SOUND_PLAY, SOUND_PAUSE, and PLAY_PROGRESS events as well.

 

I attached a fixed version of your file and I took it a step further - I fade the volume up on rollover and down on rollout using TweenLite. As you'll see, it's super simple with the new capabilities. If you'd rather just make the sound start/stop, you can call pauseSound() and playSound() respectively. Or start the sound over with gotoSoundTime(0, true).

 

Hope that helps!

 

Snag the latest version at http://www.LoaderMax.com

Link to comment
Share on other sites

Hi Jack,

 

I think you are a genius, if it wasn't for your very user friendly code and your even friendlier replies to all my simpleton questions, I would have given up on action script a long time ago.

I find it hard to wrap my head around AS, but with your classes I can do enough to impress my clients and keep them happy!

 

One problem I was encountering and why I pasted the loader inside my function was that when I loaded the sound outside the function, on button1 roll over it would play, and when I used the sound on another button2 on roll-over, it wouldn't play again when I rolled over the first button1, but that was solved when I had the sound load within the function, on each button.

 

I will try and recreate that as my original file is too big for your upload.

 

Again, thanks for your help!

 

Fam

Link to comment
Share on other sites

Yeah, I'd love to see that problem recreated in another FLA if you don't mind. You should be able to play the sound again and again regardless of the button you attach your listeners to (or if there are multiple ones). However, if you want the one sound to play twice SIMULTANEOUSLY, then you'd obviously need two copies of the sound for that to happen.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...