yuetyeelo2855 / tweener

Automatically exported from code.google.com/p/tweener
0 stars 0 forks source link

Tweening large distances causes snapping into place rather than smooth tween #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Tween an MC a large distance... couple thousand pixels maybe.
2.
3.

What is the expected output? What do you see instead?
Instead of smoothly tweening to the final destination, the clip slows
almost to a stop before reaching its target and then snaps into place.

What version of the product are you using? On what operating system?
AS2 version on Windows

Please provide any additional information below.

Original issue reported on code.google.com by ben.clin...@gmail.com on 24 May 2007 at 7:44

GoogleCodeExporter commented 9 years ago
Hello ben, 

Can you paste some of the code you're using, or a small sample .fla perhaps?

Original comment by zisfor...@gmail.com on 25 May 2007 at 3:36

GoogleCodeExporter commented 9 years ago
Ok, I've been testing and I was able to test this. Indeed, there's a certain 
snap
under these conditions:

1. using the default ("easeoutexpo") transition only, apparently;
2. moving from a log distance (as mentioned).

Because the equation function tries to approach the result of an exponential
progression, there's a slight error before the final frame of the animation; the
error margin seems to be *exactly* 0.1% of the total moved area.

It has been featured on Robert Penner's equations since they've been released, 
so you
can see the same problem with MC Tween or with any other Tweening engine. Funny
enough, it's the first time I see this snap being discussed. Odd.

Anyhow, while the snap can be fixed, there's a visual caveat. At those long
distance/values, the easeoutexpo equation loses its meaning - it doesn't look 
like
the original, eased out exponential transition it originally was, because it 
*will*
come to a sudden stop instead of decelerate until it stops. This can be "fixed" 
by
increasing the strength of the deceleration (the "-10" used the equation), but 
it
also makes the acceleration much stronger, increasing the contrast on the 
transition.

I've fixed this on Tweener, making the calculation to take the error margin into
account. Thanks.

But for your *specific* case, you have two better, alternative solutions, 
though:

1. Use other transition type for a more smoother transition. For "easeoutexpo",
"easeoutquint" is a good substitute.
2. Use a custom equation tweaked to your needs. For example, for the "fixed"
equation, you can use this:

{{{
var easeOutExpoRight:Function = function (t:Number, b:Number, c:Number,
d:Number):Number {
    return (t==d) ? b+c : (c*1.001) * (-Math.pow(2, -10 * t/d) + 1) + b;
};
Tweener.addTween(mymc, {_x:100, time:2, transition:easeOutExpoRight});
}}}

Or for a smooth deceleration with no sudden stop (but again, with stronger 
aceleration):

{{{
var easeOutExpoRightLong:Function = function (t:Number, b:Number, c:Number,
d:Number):Number {
    return (t==d) ? b+c : c * (-Math.pow(2, -16 * t/d) + 1) + b;
};
Tweener.addTween(mymc, {_x:100, time:2, transition:easeOutExpoRightLong});
}}}

Original comment by zisfor...@gmail.com on 28 May 2007 at 1:18

GoogleCodeExporter commented 9 years ago
Thanks Zeh, great to see this addressed so quickly. I do seem to have a knack 
for
running into issues nobody else has experienced before. Not sure if that's good 
or
bad. :)

I also wanted to mention that you've created a great product in Tweener. I had
written my own wrapper classes for Tween, but the syntax/simplicity of Tweener 
is so
nice I've abandoned my library in favor of it. Thanks!

Original comment by ben.clin...@gmail.com on 28 May 2007 at 12:43

GoogleCodeExporter commented 9 years ago
Thanks again, ben.

I've been re-reading my post above and I know it sounds a bit confusing. It was
late/early in the morning so forgive any lack of proofreading or mixed 
paragraphs. :)
It suffices to say the snap has been fixed on ease[Out/In/OutIn/InOut]Expo and 
it is
rolled on the last SVN version (1.25.57), however.

Original comment by zisfor...@gmail.com on 28 May 2007 at 2:24