//初始化
mymc.stop();
//播放
function playAnimaction(evt:MouseEvent):void{
mymc.play();
//移除倒放时间侦听
mymc.removeEventListener(Event.ENTER_FRAME,everyframe);
}
//暂停
function stopAnimaction(evt:MouseEvent):void{
mymc.stop();
mymc.removeEventListener(Event.ENTER_FRAME,everyframe);
}
//逐帧向前播放
function nextAnimaction(evt:MouseEvent):void{
mymc.nextFrame();
mymc.removeEventListener(Event.ENTER_FRAME,everyframe);
}
//逐帧向后播放
function prevAnimaction(evt:MouseEvent):void{
mymc.prevFrame();
mymc.removeEventListener(Event.ENTER_FRAME,everyframe);
}
//倒放
function everyAnimaction(evt:MouseEvent):void{
mymc.addEventListener(Event.ENTER_FRAME,everyframe);
}
//跳转
function gotoAnimaction(evt:MouseEvent):void{
mymc.gotoAndStop(20);
mymc.removeEventListener(Event.ENTER_FRAME,everyframe);
}
//自定义倒放函数
function everyframe(evt:Event):void{
//若当前帧为第一帧 跳到最后播放
if(mymc.currentFrame == 1){
mymc.gotoAndStop(mymc.totalFrames);
}else{
mymc.prevFrame();
}
}
//注册按钮侦听
btn_play.addEventListener(MouseEvent.CLICK,playAnimaction);
btn_stop.addEventListener(MouseEvent.CLICK,stopAnimaction);
btn_next.addEventListener(MouseEvent.CLICK,nextAnimaction);
btn_prev.addEventListener(MouseEvent.CLICK,prevAnimaction);
btn_every.addEventListener(MouseEvent.CLICK,everyAnimaction);
btn_goto.addEventListener(MouseEvent.CLICK,gotoAnimaction);