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.
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);