[英]Restarting sound files in AS3
stop(); 停();
var mySound:Sound = new MyFavSong();
var myChannel:SoundChannel = new SoundChannel();
var lastPosition:Number = 0;
myChannel = mySound.play();
pause_btn1.addEventListener(MouseEvent.CLICK, onClickPause);
function onClickPause(e:MouseEvent):void
{
lastPosition = myChannel.position;
myChannel.stop();
}
play_btn1.addEventListener(MouseEvent.CLICK, onClickPlay);
function onClickPlay(e:MouseEvent):void
{
myChannel = mySound.play(lastPosition);
}
I am trying to make a restart button however everything I have read is not correctly working on bringing it back to the start of the sound. 我正在尝试创建一个重新启动按钮,但是我阅读的所有内容都无法正常工作,无法将其恢复到声音的开始。 I am not really great with flash so I made it as simple as I could.
我对Flash并不是很满意,所以我尽可能地简化了它。 Any and all help would be great.
任何帮助都会很棒。
Your code is fine and that's the correct way to implement a pause/play method in as3. 您的代码很好,这是在as3中实现暂停/播放方法的正确方法。
That means the problem is elsewhere. 这意味着问题出在其他地方。 Print lastPosition at the start of your onClickPlay function.
在onClickPlay函数的开始处打印lastPosition。 Is it printing something other than 0?
是否打印了0以外的内容?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.