tweening alternative
January 31st, 2005
1 comment
Hello blog fans and happy new year. Recent news for the multitude of readers of this blog: I have joined the team at gskinner.com and I'm learning a lot! Flash all day every day. The guys are constantly feeding me with cool and better ways of doing things. Here is one such technique:
A previous blog mentioned the tween class, which itself has a certain amount of overhead. Here is a more direct technique to do the same thing.
Actionscript:
-
myIntervalID:Number = setInterval(this, "tweenOutPin", 50, myMovieClip, oldX, newX, oldY, newY, getTimer(), duration);
-
-
function tweenOutPin(p_pin:MovieClip, p_oldX:Number, p_newX:Number, p_oldY:Number, p_newY:Number, p_startTime:Number, p_duration:Number):Void {
-
var t:Number = getTimer()-p_startTime;
-
if (t <= p_duration) {
-
p_pin._x = linearTween(t, p_oldX, p_newX-p_oldX, p_duration);
-
p_pin._y = linearTween(t, p_oldY, p_newY-p_oldY, p_duration);
-
} else {
-
p_pin._x = p_newX;
-
p_pin._y = p_newY;
-
clearInterval(myIntervalID);
-
}
-
}
Categories: Flash development
