PDA

View Full Version : tweening?



iceman
December 28th, 2003, 12:24 PM
Hi everyone,

I was wondering if anyone could aid me in understanding how to apply this code to an actual movieclip and have it move.
Math.linearTween = function (t, b, c, d) {
return c*t/d + b;
};

Thanks A Lot

Kyle:thumb:

pom
December 28th, 2003, 06:07 PM
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=23766&highlight=robert+penner

Robert Penner's easing equations can be tricky :)

iceman
December 29th, 2003, 12:23 AM
Thanks A Lot Ilyas, I have another question concerning the code form that post.
MovieClip.prototype.linearTween = function(endx, endy, duration) {
var x = (endx-this._x)/duration, y = (endy-this._y)/duration, t;
this.onEnterFrame = function() {
if (t++ <duration) {
this._x += x;
this._y += y;
} else {
delete this.onEnterFrame;
}
};
};
ball_mc.linearTween(400, 0, 50);
In the line:
if (t++ <duration) {
If I remove ++ the tweening continues and doesn't stop and even if I trace(t) it is outputed as undefined so I was wondering why the significant difference.

Thanks again

Kyle:p:

iceman
December 30th, 2003, 11:15 AM
anyone?