我有 2 个按钮:1 个恢复(onBtn)和 1 个暂停(offBtn),用于控制动画的声音。暂停按钮工作正常,但当我再次播放时......它从头开始重新播放歌曲而不是打开假设 resumeTime ......这是我的代码......
import flash.events.Event;
import flash.events.MouseEvent;
onBtn.addEventListener(MouseEvent.CLICK, startMove);
offBtn.addEventListener(MouseEvent.CLICK, stopMove);
var resumeTime:Number = 0;
var isPlaying:Boolean;
var mySound:Sound = new MySong();
var channel1:SoundChannel = new SoundChannel();
onBtn.visible=false;
isPlaying=true;
channel1=mySound.play();
function stopMove(event:MouseEvent):void {
resumeTime=channel1.position;
channel1.stop();
onBtn.visible =true;
offBtn.visible=false;
isPlaying=false;
stop();
}
function startMove(event:MouseEvent):void {
channel1=mySound.play(resumeTime);
onBtn.visible=false;
offBtn.visible=true;
isPlaying=true;
play();
}