I`m loading and playing sound like below.
//SOUND LOAD
var snd:Sound = new Sound();
snd.load(new URLRequest("sound.mp3"));
snd.addEventListener(IOErrorEvent.IO_ERROR, onIOError, false, 0, true);
snd.addEventListener(Event.COMPLETE, onSoundLoadComplete, false, 0, true);
function onIOError(evt:IOErrorEvent):void{
trace("sound loading error: ",evt.text);
}
function onSoundLoadComplete(evt:Event):void{
trace("sound loaded");
}
//SOUND PLAY
snd_btn1.addEventListener(MouseEvent.MOUSE_OVER,sndPlay);
function sndPlay(evt:Event):void{
var channel:SoundChannel
channel = snd.play();
}
i would like to have my sound to play only when it`s not already playing.
how can I achieve this?
thank you