恢复动作脚本3的音乐按钮

时间:2013-02-10 02:43:31

标签: actionscript-3 flash

我有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();
}

1 个答案:

答案 0 :(得分:0)

将动画放在单独的MovieClip然后stopMove()startMove()上,然后调用play()的{​​{1}}和stop()函数。

以下是一个有效的例子:http://www.swfcabin.com/open/1360494138

代码中的更改:

MovieClip