code:
import fl.transitions.easing.*;
import index.base.animation.motion;
import index.base.events.motionevent;
//算法数组
var classar:array = [back,bounce,elastic,none,regular,strong];
//初始小方块
var mc:mc = new mc;
mc.y = 150;
addchild(mc);
//动画声明
var motion:motion = new motion(mc,"x",back.easein,50,350,40);
motion.addeventlistener(motionevent.motion_updata,motionupdatafun);
motion.addeventlistener(motionevent.motion_stop,motionstopfun);
motion.addeventlistener(motionevent.motion_play,motionplayfun);
motion.addeventlistener(motionevent.motion_finish,motionfinishfun);
motion.play();
//动画播放完毕
function motionfinishfun(e:motionevent){
tracetext.appendtext("播放完毕\n");
motion.isback ? motion.play() : motion.back();
tracetext.scrollv = tracetext.maxscrollv;
}
//屏幕更新
function motionupdatafun(e:motionevent){
currenttext.text = motion.current.tostring();
tracetext.appendtext("屏幕更新,当前帧 " motion.current ",x属性:" mc.x "\n");
tracetext.scrollv = tracetext.maxscrollv;
}
//动画播放
function motionplayfun(e:motionevent){
tracetext.appendtext("开始播放\n");
tracetext.scrollv = tracetext.maxscrollv;
}
//动画停止
function motionstopfun(e:motionevent){
tracetext.appendtext("停止播放\n");
tracetext.scrollv = tracetext.maxscrollv;
}
//侦听各个面板的change事件
classlist.addeventlistener("change",changefun);
funclist.addeventlistener("change",changefun);
durationbar.addeventlistener("change",changefun);
playbutton.addeventlistener("click",clickfun);
//当属性面板发生数值改变,即触发
function changefun(e:event){
motion.rewind();
motion.algorithm = classar[classlist.selecteditem.data][funclist.selecteditem.data];
motion.duration = durationbar.value;
durationtext.text = durationbar.value.tostring();
}
//播放按钮
function clickfun(e:event){
if(playbutton.selected) motion.resume();
else motion.stop();
}
//4个倒带前进等按钮事件
prevbutton.addeventlistener(mouseevent.click,function(){motion.prev()});
nextbutton.addeventlistener(mouseevent.click,function(){motion.next()});
forwardbutton.addeventlistener(mouseevent.click,function(){motion.forward()});
rewindbutton.addeventlistener(mouseevent.click,function(){motion.rewind()});
如对本文有疑问, 点击进行留言回复!!
flash怎么返回上一步? flash撤销操作的三种使用方法
网友评论