# Multiple Sounds Using ActionScript

**URL:** <https://forum.kirupa.com/t/multiple-sounds-using-actionscript/5733>\
**Category:** flash\
**Created:** [September 20, 2002, 2:16pm UTC](https://forum.kirupa.com/t/multiple-sounds-using-actionscript/5733 "2002-09-20T14:16:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vatrick](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@Vatrick](https://forum.kirupa.com/u/Vatrick)\
**Post date:** [September 20, 2002, 2:16pm UTC](https://forum.kirupa.com/t/multiple-sounds-using-actionscript/5733/1 "2002-09-20T14:16:11Z")

</div>

Hi, I’ve created a small application that links various Sound Clips to corresponding Sound variables, and the individual start and stop commands work fine. However, when I try altering the volume, the controls affect all the sounds in the movie.

Any suggestions? I’d like to refrain from creating separate SWF files to represent each sound, but I will if I have 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 20, 2002, 2:52pm UTC](https://forum.kirupa.com/t/multiple-sounds-using-actionscript/5733/2 "2002-09-20T14:52:09Z")

</div>

You need to scope your sound objects.

I’m guessing that you’ve probably declared you sound objects using something along the lines of:

ding = new Sound();  
ding.attachSound(“ding”);  
ding.start();  
ding.setVolume(50)

That works fine however, as you’ve found, the setVolume() method affects the global sound object.

The solution is to define a target for each new sound object you declare: this can be a movie clip instance or a level

e.g.

ding = new Sound(mc1);  
ping = new Sound(mc2);

If you’re using a lot of sound you might want to consider writing a sound function that checks for existing targeted sound instances and creates new ones in a sequential fashion

You can then target each sound object independently using the setVolume() method.

The end result will probably look something like

ding = new Sound(mc1);  
ding.attachSound(“ding”);  
ding.start(0, 50);

ping = new Sound(mc2);  
ping.attachSound(“ping”);  
ping.start(0, 50);

ding.setVolume(50)  
ping.setVolume(10)
