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()});
新聞熱點
疑難解答