View Full Version : Sound button - Mute / On/Off ?
Iconoclast
12-06-2008, 05:31 PM
Hi guys, I'm making a website in Flash and I'd like to put some music in the background, but I'd also like to include a button for the user to be able to disable/enable it as they please.
However, just about every tutorial I've come across with sound buttons only STOPS the sound, and when the user clicks the play button, it starts from the beginning again.
Is there a way I can make a button either mute or set the volume to 0, and then when clicked again have it restore it back to full without starting from the beginning again? Thanks!
BLiZZaRD
12-06-2008, 05:33 PM
Yup, you can.
Easy to follow tutorial here (http://www.kirupa.com/developer/mx/volume_slider.htm)
Iconoclast
12-06-2008, 05:37 PM
Excellent, thanks mate!
Also, another question while I'm at it...in my site I've got both sound effects (for button rollovers, clicks, etc.) and I want to put in like I said background music.
All the sound effects sound fine, but when I drag an .mp3 I import to the library onto the keyframe I want it to start playing on, when I publish the site the music sounds really poor quality, as if its being played through a tube or something. I don't understand why, because when I test the settings of the file in the library (right click > properties > test) it sounds perfectly normal, as good as it does when I listen to it in iTunes.
I've also tried changing the publish settings to up the bitrate to the maximum 160kpbs (my .mp3 file is encoded @ 192). I've also tried googling and looking up a lot of stuff on it but I haven't found anything...any ideas?
BLiZZaRD
12-06-2008, 06:05 PM
MP3 files always start out at a certain "sampling rate-" a certain number of cycles per second. For our purposes it's good enough to know that high sampling rates sound great, and low sampling rates sound... not so great. But for speech and one-person acoustic performances, they can be just fine.
The problem is that Flash Player only supports two sampling rates: 22,050 samples per second, and 44,100 samples per second.
Here is a list (http://www.articulate.com/blog/flash-supported-mp3-settings/) of Flash supported bit-rates (you can ignore the rest)
This PDF (http://clear.msu.edu/dennie/flash/docs/3.pdf) (for version 8) will show some settings to use when publishing. Give them a try.
Iconoclast
12-06-2008, 07:10 PM
I'm giving the volume tutorial a try, but as I'm doing it it feels like I'm doing a lot of extra work for nothing...to be honest I'd rather have a mute button instead of a slidebar; not only would it take up less space but from what I can imagine it should be easier to do...do you know of any tutorials for that?
PS - Thanks for the links, I'll look at those and see if I can fix my music sound.
BLiZZaRD
12-06-2008, 07:43 PM
Mute Button Video Tutorial (http://www.photoshopsupport.com/flash/tt/flash-mute-sound.html)
Iconoclast
12-06-2008, 08:29 PM
I've actually stumbled across that tutorial before in my search for a mute button, but it STOPS the sound when a user clicks it, and when unmuted, the sound starts over from the beginning =/
Medyman
12-07-2008, 12:24 AM
So, you want to basically pause the audio? Is that correct? If not, you might consider going about it that way. Muting the audio means that all of the resources that are used in that functionality remain in use -- not the best way to go.
Iconoclast
12-07-2008, 12:51 AM
If there is a SIMPLE way to PAUSE the audio without it RESTARTING when the user clicks play, then yes I would be very interested :)
Medyman
12-07-2008, 01:28 AM
If there is a SIMPLE way to PAUSE the audio without it RESTARTING when the user clicks play, then yes I would be very interested :)
lol, depends on your definition of simple. AS2 doesn't actually support pausing so you have to fake it. I think it's easy.
Bascially, when someone clicks the pause button you:
1) Stop the audio
2) Get the position of the audio
3) Save the position in a variable.
Then, when someone enables the audio again, you refer to the position stored in the variable and begin playing the audio from that marker.
If you're interested, Lee Brimelow goes over this technique in his video tutorials over at gotoAndLearn(). I'm not sure which tutorial it is. But, I remember him covering it in one some time ago.
Iconoclast
12-07-2008, 06:14 AM
Ok, I used this tutorial: http://www.gotoandlearn.com/play?id=8, and I did everything, but there's one difference that I can't seem to figure out what to do with.
In the tutorial, he's using the button to mute the sound in an flv, whereas I want to use the mute button to mute sound in my swf. The only part I don't get is this:
_root.createEmptyMovieClip("vSound",_root.getNextHighestDepth())
vSound.attachAudio(ns);
var so:Sound = new Sound(vSound);
But what he's doing there is stripping the sound from the "netstream" (ns) which is coming from the flv...what do I do if my sound is just in the library, and it starts playing on a keyframe on a layer in my flash file?
Medyman
12-07-2008, 04:59 PM
The video I was referring to actually was \ (http://www.gotoandlearn.com/play?id=38). Give it a look and then let me know if you have any questions.
You may need to watch Part I of the series for background.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.