Reputation: 13
I am trying to create an audio Mixer application in Flash using Action Script 3. The application has 9 buttons when a button is clicked a sound will loop, from an external mp3. I can get the sound to play (not looped) when the button is clicked, but cannot figure out how to allow multiple sounds to be played at once, when more than one buttons is clicked.
Here is my code to play the sound:
var req:URLRequest = new URLRequest("Sound/Melody1.mp3");
var sound:Sound = new Sound();
var controller:SoundChannel;
function soundLoaded(event:Event):void
{
controller = sound.play();
controller.stop();
Btn_Melody1.addEventListener(MouseEvent.CLICK, playSound);
}
function playSound(event:MouseEvent):void
{
controller = sound.play();
}
sound.addEventListener(Event.COMPLETE, soundLoaded);
sound.load(req);
.
This is the first stage, next I am going to try and add a volume slider, mute, reset.
Any and all help would be appreciated, thanks in advance.
Upvotes: 0
Views: 2095
Reputation: 632
Since both your sounds are loaded with the same variable, they cannot be played together. Use different instance variables to hold different sounds. For more help visit http://www.kennybellew.com/tutorial/
Upvotes: 0