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()});
IT时代网(关注微信公众号ITtime2000,定时推送,互动有福利惊喜)所有原创文章版权所有,未经授权,转载必究。
创客100创投基金成立于2015年,直通硅谷,专注于TMT领域早期项目投资。LP均来自政府、互联网IT、传媒知名企业和个人。创客100创投基金对IT、通信、互联网、IP等有着自己独特眼光和丰富的资源。决策快、投资快是创客100基金最显著的特点。
小何
小何
小何
小何