到目前为止,我的代码停止声音,但一旦停止声音不再起作用。我没有看到任何错误报告。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:如果你的问题已经解决,那么你可以接受答案。 –