Ultrashock Forums > Flash > ActionScript
Controlling button volume via AS

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
Controlling button volume via AS
Old 2008-02-23

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
postbit arrow Be the first to comment! | 168 views postbit arrow Reply: with Quote   
Shu
Registered User
Shu is offline
seperator
Posts: 432
2001-04-20
Shu lives in Canada
seperator
Thread Tools
Display Modes Rate This Thread
Rate This Thread: