# A problem with sounds

**URL:** <https://forum.kirupa.com/t/a-problem-with-sounds/255391>\
**Category:** Uncategorized\
**Created:** [March 21, 2008, 9:47pm UTC](https://forum.kirupa.com/t/a-problem-with-sounds/255391 "2008-03-21T21:47:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![findAll](https://avatars.discourse-cdn.com/v4/letter/f/4da419/32.png) [@findAll](https://forum.kirupa.com/u/findAll)\
**Post date:** [March 21, 2008, 9:47pm UTC](https://forum.kirupa.com/t/a-problem-with-sounds/255391/1 "2008-03-21T21:47:46Z")

</div>

My problem:  
I try to build a site in Flash CS3, with sounds. The sounds in the site are events (I think this is the term), I mean they are not of type:  
[COLOR=Blue]var mySound:Sound = new Sound;  
mySound.loadSound(“anysound.mp3”, true)[/COLOR]  
but directly put in the frames. I also have sounds in other swf files that load at certain times in the main swf.  
However, in the 1st frame of one of layers of the main swf file I have this:  
[COLOR=Blue]var globalSound:Sound = new Sound;[/COLOR]  
as a global sound for the main swf file. I also have a sound on/off movieclip in the main swf. Inside the sound on/off I have (in actions layer) animation like  
[COLOR=Blue]off\_btn.onRelease = function () {  
gotoAndPlay(“off”)  
}[/COLOR]  
where off\_btn is an instance of an invisible button (inv\_btn) also inside of this movieclip and “off” is a label for a frame in the same movieclip from where the alpha starts to change. But because I want to mute all the sounds in the main swf and other swf files that load at certain times in the main swf, the entire code is something like:  
[COLOR=Blue]off\_btn.onRelease = function () {  
gotoAndPlay(“off”)  
\_parent.globalSound.setVolume(0)  
}  
[/COLOR]For “re-hearing” all sounds I have:  
[COLOR=Blue]on\_btn.onRelease = function () {  
gotoAndPlay(“on”)  
\_parent.globalSound.setVolume(100)  
}[/COLOR]  
where on\_btn is another instance of the same inv\_btn button and “on” is another label of another frame in the sound on/off movieclip where alpha changes back again. It works perfectly. In fact it works either I write \_parent.globalSound, or \_root.globalSound. It doesn’t matter for now, because, as I said, it works just fine. So what is the problem???

HERE IT IS:

I want a song to play, but without hearing other sounds. So, in the 1st frame of the mains swf, where i put  
[COLOR=Blue]var mySound:Sound = new Sound;[/COLOR]  
I also wrote  
[COLOR=Blue]var bzn:Sound = new Sound;[/COLOR]  
where bzn is the song I want to play.  
I created a new testing swf file (to load it in the main swf), a testing file in wich I have a square and a triangle (both movieclips, suggesting a stop and a play button). The scripts are not directly attached to the instances of the movieclips (square and triangle), but put in the actions layer and they look like this:  
[COLOR=Blue]triangle.onRelease = function () {  
[/COLOR][COLOR=Blue]\_parent.bzn.loadSound(“bzn.mp3”, true)  
}  
square.onRelease = function () {  
\_parent.bzn.stop()  
}[/COLOR]  
It is ok, it works perfectly: when the testing swf file is loaded in the main swf it starts and stops the bzn song when I press (release) the “triangle” and the “square”.  
The problem is that when I press (release) the sound on/off, it mutes ALL THE SOUNDS (I expected it, in fact, because of that globalSound), that means it mutes the bzn song also.  
I am quite new in Flash and didn’t figure out a way to solve this problem, so I followed a logical path (at least I thought so). I got back to the sound on/off at this code:  
[COLOR=Blue]off\_btn.onRelease = function () {  
gotoAndPlay(“off”)  
\_parent.globalSound.setVolume(0)  
}[/COLOR]  
because I thought there might be something to do. So I modified it adding a new line:  
[COLOR=Blue] \_parent.bzn.setVolume(100)[/COLOR]  
the final code ending up like this:  
[COLOR=Blue]off\_btn.onRelease = function () {  
gotoAndPlay(“off”)  
[/COLOR][COLOR=Blue]\_parent.globalSound.setVolume(0)  
[/COLOR][COLOR=Blue] \_parent.bzn.setVolume(100)[/COLOR]  
[COLOR=Blue] }[/COLOR]  
thinking in my stupidity that even if all the sounds are muted (due to that \_parent.globalSound.setVolume(0)) the song’s volume will be kept to 100%, so I could hear the bzn song without hearing other sounds. But it wasn’t so :-/. It seems that globalSound rules everything in my main swf (as it probably should).

So, is there anyone there who could help me with my problem? I’d really appreciate it!
