# Sound Control

**URL:** <https://forum.kirupa.com/t/sound-control/6006>\
**Category:** programming\
**Created:** [September 27, 2002, 1:22pm UTC](https://forum.kirupa.com/t/sound-control/6006 "2002-09-27T13:22:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![leuchovius](https://avatars.discourse-cdn.com/v4/letter/l/2acd7d/32.png) [@leuchovius](https://forum.kirupa.com/u/leuchovius)\
**Post date:** [September 27, 2002, 1:22pm UTC](https://forum.kirupa.com/t/sound-control/6006/1 "2002-09-27T13:22:59Z")

</div>

Is there a way to mute all sounds in a whole scene?  
I want to have a button that turns off all sounds and stops  
all sounds from playing until i press the button again.  
The button is done and there’s a "set(gallerysound,1)  
instruction in it when first pressed, and then it  
changes to zero the second time around. But now I’m stuck.

How do i use this var to control the sounds in other keyframes?  
(preventing the sounds from playing until gallerysound changes again) ?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 28, 2002, 4:26am UTC](https://forum.kirupa.com/t/sound-control/6006/2 "2002-09-28T04:26:01Z")

</div>

I have found making a button perform the task easiest - slap an action onto it like this…

on (release) {  
stopAllSounds();  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 28, 2002, 7:22am UTC](https://forum.kirupa.com/t/sound-control/6006/3 "2002-09-28T07:22:30Z")

</div>

I want the button to work as a “mute” button does on a TV. While it’s in mute mode, no sound should start, but when you unmute it, sounds should be allowed again.

i have 7 keyframes, one soundclip plays in each,  
and there’s a navigation system which lets the user  
navigate through the frames.

stopAllSounds works, but then you have to  
push it every time you move to a new frame.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 28, 2002, 9:59am UTC](https://forum.kirupa.com/t/sound-control/6006/4 "2002-09-28T09:59:20Z")

</div>

Use a variable.

In your actions layer, set up the sounds

```php
sound1 = new Sound();
sound1.attachSound("linkagename");

```

To set the linkage name go to your library right click on the sound, then properties and give the linkage name.

On the button

on (release) {  
soundsoff = 1;  
}

then every keyframe where there is new sound use:

if (!soundsoff){  
\_root.bonsound.start();  
}

The sound shouldn’t start because the soundsoff variable is 1 or true.

Then on the sounds on button use:

on (release) {  
soundsoff = 0  
}

It’s only going to check everytime it comes across a command to play a sound, so it’s not a dynamic on off system.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 28, 2002, 1:46pm UTC](https://forum.kirupa.com/t/sound-control/6006/5 "2002-09-28T13:46:16Z")

</div>

This seems to be a good solution, but I’m having problems with the variable, how do I declare it? Does it have to be global?  
And if, how do I declare a global variable?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 28, 2002, 1:55pm UTC](https://forum.kirupa.com/t/sound-control/6006/6 "2002-09-28T13:55:47Z")

</div>

You can define soundoff, in a frame in the main timeline and refer to it as \_root.soundoff on the buttons and checks.

Global variables are declared using “set”. The above should work for you.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 28, 2002, 2:30pm UTC](https://forum.kirupa.com/t/sound-control/6006/7 "2002-09-28T14:30:12Z")

</div>

It works now, but now the problem is how and when to load the sounds… I can’t load all sounds into the first frame, because it gets a size above 200k. and if i don’t load it into the first frame, the sounds don’t play when i want them to.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 28, 2002, 4:14pm UTC](https://forum.kirupa.com/t/sound-control/6006/8 "2002-09-28T16:14:59Z")

</div>

This happens when you have export in first frame selected in the linkage properties.
