Groups | Blog | Home
all groups > flash actionscript > october 2005 >

flash actionscript : Controlling attached Sound files


TAGDigital
10/20/2005 10:13:20 PM
Hi all,

I am having a problem getting sounds to work correctly. I have a dozen or so
sounds that I have defined objects for...ie
var snd_music_1:Sound = new Sound();
var snd_music_2:Sound = new Sound();, etc...

I then attach sounds from the library...ie
snd_music_1.attachSound("sound_01");
snd_music_2.attachSound("sound_02");, etc...

I then start sounds at different times..ie
snd_music_1.start(0,2);
snd_music_2.start(0,1); etc...

I then put 'some' of the sounds in an array for easy access, ie...

for(i=1;i<=12;i++){
_global.soundBank_01 = eval("snd_music_"+i)
}

I can start the sound using..
_global.soundBank_01[1].start(0,1), etc...

The problem happens when I stop the sounds using...
for(i=0;i<12;i++){
_global.soundBank_01.stop()
}

This seems to stop other sounds that aren't defined in the array at all.

Then when I try to start other sounds they don't always work.

I have also tried attaching the sounds to empty movie clips to keep them
separate but that didn't seem to always work either.

I'm stumped. All I need to do is control individual sounds, start, stop,
volume
and use an array to access them. ie...mySound[x].stop(); without affecting the
other sounds that are playing.

Any thoughts???

Thanks

kglad
10/21/2005 12:53:04 AM
i think you need to define, at most, one sound object per timeline. otherwise,
your start(), stop() etc methods will control all sound objects on the implicit
timeline. try:

for(var i=1;i<=12;i++){
_root.createEmptyMovieClip("mc"+i,i);
_root["snd_music_"+i]=new Sound(_root["mc"+i]);
if(i<10){
_root["snd_music_"+i].attachSound("sound_0"+i);
} else {
_root["snd_music_"+i].attachSound("sound_"+i);
}
}
AddThis Social Bookmark Button