WEB开发网
开发学院图形图像Flash Flash AS3教程:Motion类 阅读

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 =

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()});

上一页  1 2 3 

Tags:Flash AS 教程

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接