- package{
- public class Tweens{
- public function Tweens(){}
- /*
- time:运动初始时间,一般为零
- begin:运动对象的初始属性
- change:运动对象属性的改变量
- duration:运动持续时间
- */
- //直线运动
- function lineMove(time:Number,begin:Number,change:Number,duration:Number):Number
- { return change * time / duration + begin;}
- //二次缓入
- function easeInQuad(time:Number,begin:Number,change:Number,duration:Number):Number
- { return change * (time /=duration)*time + begin; }
- //二次缓出
- function easeOutQuad(time:Number,begin:Number,change:Number,duration:Number):Number
- { return -change * (time /=duration)*(time-2) + begin; }
- //二次缓入-缓出
- function easeOutQuad(time:Number,begin:Number,change:Number,duration:Number):Number
- { if((time/=duration/2)<1)return change/2*time*time+begin
- return -change/2 *((--time)*(time-2)-1)+begin }
- //正弦缓动
- function easeInSine(time:Number,begin:Number,change:Number,duration:Number):Number
- { return change*(1-Math.cos(time/duration*(Math.PI/2)))+begin}
- function easeOutSine(time:Number,begin:Number,change:Number,duration:Number):Number
- { return change*(1-Math.sin(time/duration*(Math.PI/2)))+begin}
- function easeInOutSine(time:Number,begin:Number,change:Number,duration:Number):Number
- { return change/2*(1-Math.cos(Math.PI*time/duration))+begin}
- //圆形缓动
- function easeInCirc(time:Number,begin:Number,change:Number,duration:Number):Number
- { return change*(1-Math.sqrt(1-(time/=duration)*time))+begin}
- function easeOutCirc(time:Number,begin:Number,change:Number,duration:Number):Number
- { return change*Math.sqrt(1-(time=time/duration-1)*time)+begin}
- function easeInOutCirc(time:Number,begin:Number,change:Number,duration:Number):Number
- { if((time/=duration/2)<1){return change/2*(1-Math.sqrt(1-time*time))+begin}
- return change/2*(Math.sqrt(1-(time-=2)*time)+1)+begin}
- //指数缓动
- function easeInExpo(time:Number,begin:Number,change:Number,duration:Number):Number
- { return change*Math.pow(2,10*(time/duration-1))+begin}
- function easeOutCirc(time:Number,begin:Number,change:Number,duration:Number):Number
- { return change*(Math.pow(2,-10*time/duration)+1)+begin}
- function easeInOutCirc(time:Number,begin:Number,change:Number,duration:Number):Number
- { if((time/=duration/2)<1){return Math.pow(2,10*(time-1))+begin}
- return change/2*(-Math.pow(2,-10*--time)+2)+begin}
- /*
- obj:运动对象
- pertype:运动对象属性
- begin:运动对象属性初始状态
- center:运动中心
- factot:运动摩擦系数
- */
- //简谐运动
- function harmonic(obj:*,pertype:String,begin:Number,center:Number,factor:Number):Number{
- obj.speed = 0;
- obj.pertype=pertype
- obj.begin=begin
- obj.center=center
- obj.factor=factor
- obj.onEnterFrame = function() {
- this.speed += (this.center-this.begin)*this.factor
- this[this.pertype] += this.speed;
- };
- }
- //摩差运动的缓冲
- function buffer(obj:*,pertype:String,begin:Number,center:Number,factor:Number):Number{
- obj.pertype=pertype
- obj.begin=begin
- obj.center=center
- obj.factor=factor
- obj.onEnterFrame = function() {
- this[this.pertype] += (this.center-this.begin)*this.factor
- };
- }
- //阻尼运动
- /*
- obj:运动对象
- pertype:运动对象属性
- r:阻尼运动半径
- ang: 阻尼运动角度
- factot:阻尼运动系数
- */
- function damping(obj:*,pertype:String,r:Number,ang:Number,factor:Number):Number{
- obj.pertype=pertype
- obj.r=r
- obj.ang=ang
- obj.factor=factor
- obj.onEnterFrame = function() {
- this[this.pertype] += Math.sin(this.ang)*this.r*this.factor
- this.ang+=1
- };
- }
- }
- }
运动公式类
最新推荐文章于 2009-01-16 00:18:00 发布