# Sound volume

**URL:** https://forum.kirupa.com/t/sound-volume/28666
**Category:** Uncategorized
**Created:** [August 16, 2003, 10:36am UTC](https://forum.kirupa.com/t/sound-volume/28666 "2003-08-16T10:36:38Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![something369](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@something369](https://forum.kirupa.com/u/something369)
#### Post date: [August 16, 2003, 10:36am UTC](https://forum.kirupa.com/t/sound-volume/28666/1 "2003-08-16T10:36:38Z")

</div>

Hello, i got this code that should load a sound and slowly raise the volume for that sound. However, instead of just affecting one sound, it affects all the sounds in my movie, causing all of them to be low at first.

var bgSound, bgSoundvol;  
bgSound = new sound();  
bgSound.attachSound(“bgsound1”);  
bgSound.start(0, 1000);  
bgSound.setVolume(0);  
this.onEnterFrame = function() {  
if (bgSoundvol\>=100) {  
this.onEnterFrame = null;  
}  
bgSoundvol = bgsoundvol+5;  
bgSound.setVolume(bgSoundvol);  
};

Can anyone see why this side effect occurs?

Any help is appreciated… thank 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: [August 16, 2003, 11:25am UTC](https://forum.kirupa.com/t/sound-volume/28666/2 "2003-08-16T11:25:12Z")

</div>

```auto
var bgSound, bgSoundvol;
bgSound = new Sound();
bgSound.attachSound("bgsound1");
bgSound.start(0, 1000);
bgSound.setVolume(0);
onEnterFrame = function() {
   bgSoundvol < 100 ? bgSoundvol += 5 : null
   bgSound.setVolume(bgSoundvol);
};

```

---

<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: [August 16, 2003, 4:22pm UTC](https://forum.kirupa.com/t/sound-volume/28666/3 "2003-08-16T16:22:27Z")

</div>

You need to asign the sound to its own move clip

[AS]bgSound = new Sound(bgSoundMc);[/AS]

Any sound that insn’t defined in its own move clip when u affect it it will affect all the other sounds that are also not in there own movie clip.

---

<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: [August 16, 2003, 9:17pm UTC](https://forum.kirupa.com/t/sound-volume/28666/4 "2003-08-16T21:17:07Z")

</div>

Does that mean that all I have to is change the code to:

## ActionScript:

## bgSound = new Sound(bgSoundMc);

and add a mc named bgsoundmc for this problem to be solved?

---

<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: [August 16, 2003, 9:18pm UTC](https://forum.kirupa.com/t/sound-volume/28666/5 "2003-08-16T21:18:03Z")

</div>

it shouldn’t jsut add what i did in the brackets and test it. I’m sure it will localize the changes to jsut that sound. I believe u dont’ even have to create the MC on the stage. jsut add that ot your code. IF stilla problem then Create a MC with that instance name on the stage.

---

<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: [August 17, 2003, 11:11pm UTC](https://forum.kirupa.com/t/sound-volume/28666/6 "2003-08-17T23:11:42Z")

</div>

Thank you, your suggestions worked. To make it work all I needed to do was add your line of code, and make a mc with the corressponding instance name.

---

<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: [August 18, 2003, 12:18am UTC](https://forum.kirupa.com/t/sound-volume/28666/7 "2003-08-18T00:18:14Z")

</div>

Your welcome.
