放一个比较不错的flash缓动函数上来
函数如下:
MovieClip.prototype.smoothMove = function(sp, tx,ty) {
if(tx!=0)
this._x = this._x+sp*(tx-this._x);//缓动
if(ty!=0)
this._y=this._y+sp*(ty-this._y);//缓动
};
MovieClip.prototype.MoveTo = function(sp, sx,sy) { //函数 中第一个参数是缓动系数(取值0--1之间),sx,sy 分别是目标点x,y坐标,当值为0时为在该方向不移动。
this.age = 0;
this.onEnterFrame = function() {
if (this.age<30) {
this.smoothMove(sp, sx,sy);
} else {
delete onEnterFrame;
}
this.age++;
};
};
if(tx!=0)
this._x = this._x+sp*(tx-this._x);//缓动
if(ty!=0)
this._y=this._y+sp*(ty-this._y);//缓动
};
MovieClip.prototype.MoveTo = function(sp, sx,sy) { //函数 中第一个参数是缓动系数(取值0--1之间),sx,sy 分别是目标点x,y坐标,当值为0时为在该方向不移动。
this.age = 0;
this.onEnterFrame = function() {
if (this.age<30) {
this.smoothMove(sp, sx,sy);
} else {
delete onEnterFrame;
}
this.age++;
};
};
调用的例子:
//水平缓动:
anyMovieClip.MoveTo(0.2, 200,0);
//垂直
anyMovieClip.MoveTo(0.2, 0,200);
//各个方向
anyMovieClip.MoveTo(0.2, 200,300);
anyMovieClip.MoveTo(0.2, 200,0);
//垂直
anyMovieClip.MoveTo(0.2, 0,200);
//各个方向
anyMovieClip.MoveTo(0.2, 200,300);