Hi guys, sorry i seem to be posting a lot at the moment but i am trying to get my Flash Skills up to date, hope im not annoying anyone too much :).
Basically i have a small project where pressing a button will trigger a sound, So when i click ‘Button1’ it plays the sound assigned to ‘Button1’, I have done this like the following.
//variables for button sounds
var playlistArray:Array = new Array();
var buttonsOnArray:Array = new Array();
mainHold.Bass1_mc.fileName="bass1.mp3"
mainHold.Bass2_mc.fileName="bass2.mp3"
//event listeners for sound buttons
mainHold.Bass1_mc.addEventListener(MouseEvent.CLICK, soundSelected);
mainHold.Bass2_mc.addEventListener(MouseEvent.CLICK, soundSelected);
function soundSelected(evt:MouseEvent):void{
playlistArray.push(evt.target.fileName);//pushes the filename into a playlist array.
buttonsOnArray.push(evt.target.name);//pushes the instance names of the buttons 'on'.
trace ("PlayList = "+playlistArray);
trace ("Buttons On are ="+buttonsOnArray);
for (var i:int = 0; i < playlistArray.length; i++)
{
var channel = new SoundChannel;
snd.load(new URLRequest(evt.target.fileName));
channel = snd.play();
snd.play(0,9);
}
One sound will play fine, however, i cannot make two sounds play at the same time. The error i get is.
Error: Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful.
at flash.media::Sound/_load()
at flash.media::Sound/load()
at loopwall_fla::MainTimeline/soundSelected()
Eventually i am going to have 20 different sounds, i know i need to probably assign each sound to its own individual sound channel. i tried manipulating the for statement to say something like var *Channel = new SoundChannel; in the hope that it would assign a number next to the SoundChannel thus making it unique, but nope.
Any help would be, as always, greatly appreciated
Thanks!