Flash AS3教程:Motion类
2008-06-05 11:21:53 来源:WEB开发网algorithm属性:
public var algorithm:Function;
设置对象从初始值到结束值是以什么算法进行运动
受保护的属性:
protected var _current:uint = 0;
protected function updata(isInit:Boolean = false):void
如果继承该类,则可以访问_current属性和updata方法,可以直接修改当前帧和强制更新屏幕
举例:(上面那个展示flash的源代码)
对于各种不同的算法,进行效果展示,小小的偷了一下懒,使用的flash自带组件。。
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("播放完毕
");
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 + "
");
traceText.scrollV = traceText.maxScrollV;
}
//动画播放
function motionPlayFun(e:MotionEvent){
traceText.appendText("开始播放
");
traceText.scrollV = traceText.maxScrollV;
}
//动画停止
function motionStopFun(e:MotionEvent){
traceText.appendText("停止播放
");
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()});
- ››ASP.NET及JS中的cookie基本用法
- ››ASP.NET获取MS SQL Server安装实例
- ››asp.net实现调用百度pai 在线翻译英文转中文
- ››ASP.NET页面选项进行提示判断
- ››Asp.net定时执行程序
- ››ASP.NET中利用DataList实现图片无缝滚动
- ››ASP.NET验证控件RequiredFieldValidator
- ››ASP.NET中使用System.Net.Mail发邮件
- ››ASP.NET中获取用户控件中控件的ID
- ››ASP.NET中FileBytes写成文件并存档
- ››asp获取毫秒数
- ››asp.net报“INSERT INTO 语句的语法错误解决
更多精彩
赞助商链接