Hi,
I’ve got an array of Strings each of which have been input by a series of coloured buttons with sounds attached. When a play button is pressed the strings that correspond to different coloured sounds should play one after the other. Instead they all play at the same time as one jumbled mess of noise and I have tried everything to get it to work. The trace shows that the for loop through the array seems to be doing the right thing which is why I can’t understand why it won’t just play back one after the other.
This is the code for the play button
PlayBTN.onRelease = function(){
trace("PlayButton Pressed");
for(var i:Number =0; i<songArray.length; ++i){
trace("Inside Loop");
trace(i);
if(songArray*=="Orange"){
OrangeSound.start(0,1);
trace("Playing ORANGE Sound");
//var interval = setInterval(wait,5000);
//clearInterval(interval);
}
else if(songArray*=="Pink"){
PinkSound.start(0,1);
trace("Playing PINK sound");
}
else if(songArray*=="Yellow"){
YellowSound.start(0,1);
trace("Playing YELLOW Sound");
}
else if(songArray*=="Blue"){
BlueSound.start(0,1);
trace("Playing BLUE Sound");
}
else if(songArray*=="Green"){
GreenSound.start(0,1);
trace("Playing GREEN Sound");
}
else if(songArray*=="Red"){
RedSound.start(0,1);
trace("Playing RED Sound");
}
}
This is how the sounds (words corresponding to sounds) are put in the array:
OrangeButton.onRelease = function(){
if(FreeIndex<10){
OrangeSound = new Sound();//When coloured buttons are pressed they make the sound that corresponds in the library
OrangeSound.attachSound("OrangeSound");//the name of the sound in the library
OrangeSound.start(0,1);//They only make the sound for one loop
songArray[FreeIndex] ="Orange";
(Each colour having its own block of code similar to this.
Please help!