Hi Folks,
I've been searching the forums trying to find a way to create a global volume controller for my sound effects (notably the button sound effects) but was unable to find a solution, so I came up with my own and I figure I'd share.
First of all, I really don't like the idea of having to use code for my button event sounds unless I really need to. Adding sounds via flash's timeline seems so much cleaner to me. The problem is that you can't use the Sound object to control timeline sounds that are in buttons (why, oh why??). However, you can control timeline sounds for Movieclips... the solution? Make each button state a Movieclip and add the timeline sound in the Movieclip! From there, its really simple - create the sound object as you normally would:
var s_sound = new Sound(target_mc*);
s_sound.setVolume(20);
*Note: target_mc is the movieclip containing your interface (which holds the buttons).
This will allow you to controll all sound events (in the target_mc) added via the timeline. If you want to add other sounds, (say background music) and have a separate controller for that, you'll need to make sure the background music target mc is outside of the s_sound target mc - or it will get grouped with them.
Hope this helps!
Shu