到目前爲止,我的代碼停止聲音,但一旦停止聲音不再起作用。我沒有看到任何錯誤報告。Flash AS3音頻播放器似乎只是停止工作
這是因爲如果該事件偵聽器不再偵聽...
stop();
var soundClip:Sound = new Sound();
var sndChannel:SoundChannel = new SoundChannel();
var soundClipCompleted = false;
var isPlaying = false;
soundClip.load(new URLRequest("tune.mp3"));
soundClip.addEventListener(Event.COMPLETE,onComplete,false,0,true);
function onComplete(evt:Event):void {
sndChannel=soundClip.play();
soundClipCompleted=true;
isPlaying = true;
Action_BtnPlay.gotoAndStop(2);
}
Action_BtnPlay.addEventListener(MouseEvent.MOUSE_UP, playBtn);
function playBtn (evt:MouseEvent):void {
if(isPlaying && soundClipCompleted){
sndChannel.stop();
Action_BtnPlay.gotoAndStop(1);
}else{
sndChannel = soundClip.play();
Action_BtnPlay.gotoAndStop(2);
}
}
非常感謝:) –
@ WebOD-Bradley:如果你的問題已經解決,那麼你可以接受答案。 –