Friday, September 19, 2008

Flash move dynamically


_global.moveXY = function(targetx,targety,speed) {
goAnimate = function() {
this._x += (targetx - this._x)/speed;
this._y += (targety - this._y)/speed;

if((Math.abs(this._x - targetx) < 0.5) && (Math.abs(this._y - targety) < 0.5)) {
delete this.onEnterFrame;
}
}
this.onEnterFrame = goAnimate;
}


to use the script,
_global.moveXY.call(movieClip name, x, y, speed);

No comments: