我已经使用Flash AS3创建了声音的开/关按钮。这些有效,但是每当我按关闭按钮然后按打开按钮时,音乐就不会再次播放吗?
我认为这是一个循环的问题,但我能说错吗?我不确定如果出现循环问题要使用什么代码。
我还需要为btnOn函数添加代码,因为当我打开.swf时,声音会自动播放。
附件是我当前的代码如下:
var mySound:Sound = new sandstorm(); //(sandstorm is my sound file)
var myChannel:SoundChannel = new SoundChannel();
var lastPosition:Number = 0;
myChannel = mySound.play();
btnOff.addEventListener(MouseEvent.CLICK, onClickPause);
function onClickPause(e:MouseEvent):void {
lastPosition = myChannel.position;
myChannel.stop();
}
干杯:)
最佳答案
您的代码仅显示事件侦听器onClickPause(我想这就是您的停止按钮)。但是开始/播放按钮的事件监听器在哪里。在播放按钮上,您必须再次调用播放功能。这是一个很棒的教程:http://www.republicofcode.com/tutorials/flash/as3sound/
关于actionscript-3 - 循环声音闪烁as3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39015221/