Groups | Blog | Home
all groups > flash actionscript > august 2007 >

flash actionscript : Turn off All Sounds


David Stiller
8/31/2007 4:23:46 PM
siney,

[quoted text, click to view]

You can. As dbeech mentioned, the Sound class acts globally in
ActionScript 2.0 if you omit a target in the constructor to the Sound class.
This basically means you can easily create a global volume control as
described here (doesn't matter if your sounds are timeline based or
ActionScript-based):

http://www.quip.net/blog/2006/flash/how-to-toggle-sound-globally


David Stiller
Contributor, How to Cheat in Flash CS3
http://tinyurl.com/2cp6na
"Luck is the residue of good design."

siney
8/31/2007 6:06:27 PM
I've got an application that I'm building that uses a variety of sound effects.
These are currently sprinkled throughout the app. in buttons, mcs & 1 or 2 on
the main timeline. Is there an easy way to add a button to turn off all sounds,
if the user doesn't want them? I've tried applying the "turnoffallsounds" to no
avail. Any help would be appreciated! Thanks.
kglad
8/31/2007 6:21:10 PM
clbeech
8/31/2007 6:32:19 PM
siney
8/31/2007 6:55:20 PM
kglad
8/31/2007 10:02:39 PM
clbeech
8/31/2007 10:14:04 PM
yes, but this will not 'stop' the sounds, do that as kglad indicated above,
however when the playhead moves again the sounds will play when initiated. to
use the setVolume(0) method you will need to target any of the sounds you
already have, or create a 'global' sound to use for this purpose. Like on
frame1 main timeline, create a generic Sound Object, doesn't even need to have
a sound attached,

var mute:Sound = new Sound();

then from the button, target that Object by:

on(press) {
_level0.mute.setVolume(0);
}

use setVolume(100) to resume.
clbeech
9/1/2007 12:00:00 AM
siney
9/1/2007 4:04:33 AM
Hey thanks for the timely replies all! Much appreciated. & David Stiller! I'm a
big fan of your blog! (although admittedly I must have missed that pointedly
direct solution of ' how to toggle sound globally ' article) -- Thanks. Seems
very simple - giving it a whirl now.

And directly after KGlad & clbeech replied - apparently the whole shootin'
match went down for a while for some scheduled work. Nice timing.

But thanks again all.
kglad
9/1/2007 4:35:58 AM
AddThis Social Bookmark Button