I made a speaker check. That is working fine. But if i duble click speakrOn button sound playing 2 times (two audios at a time).
How to solve my problem?
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
mySound.load(new URLRequest("testAudio.mp3"));
speakrOn.addEventListener(MouseEvent.CLICK, onClickPlay);
speakrOff.addEventListener(MouseEvent.CLICK, onClickPlay);
function onClickPlay(e:MouseEvent):void
{
speakrOn.visible = true;
speakrOff.visible = false;
myChannel = mySound.play();
myChannel.addEventListener(Event.SOUND_COMPLETE, onAudioCompleteHandler);
}
function onAudioCompleteHandler(e:Event):void
{
speakrOn.visible = false;
speakrOff.visible = true;
}
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
var isPlaying:Boolean = false;
mySound.load(new URLRequest("testAudio.mp3"));
speakrOn.addEventListener(MouseEvent.CLICK, onClickPlay);
speakrOff.addEventListener(MouseEvent.CLICK, onClickPlay);
function onClickPlay(e:MouseEvent):void
{
speakrOn.visible = true;
speakrOff.visible = false;
if (!isPlaying)
{
myChannel = mySound.play();
myChannel.addEventListener(Event.SOUND_COMPLETE, onAudioCompleteHandler);
isPlaying = true;
}
}
function onAudioCompleteHandler(e:Event):void
{
isPlaying = false;
speakrOn.visible = false;
speakrOff.visible = true;
}
North America
Europe, Middle East and Africa
Asia Pacific