[Tweener] Instant tween
Zeh Fernando
zeh at zehfernando.com
Wed Aug 6 11:30:58 PDT 2008
> I'm pretty certain this has been asked already as it looks like a
> useful feature. I did take a look around but didn't quite find the
> answer though.
>
> What I'd use is a quick function that takes the parameters of a
> tweening object, ignores all Tweener-specific ones (time, transition,
> _color, _bezier...) and instantly applies the values without having to
> go through all the needless Tweener code.
>
> As far as I've peeked in the code Tweener already does this, however
> there are two disadvantages. The first is that I use private static
> const objects to store all the tweening parameters. If I want an
> instant tween I have to clone the objects via a quick bytearray
> function and set the time to zero - not so quick if you're doing it en
> masse. The second disadvantage is that I'm kind of strict about my
> code and using Tweener to _instantly_ change the parameters isn't
> immediately obvious.
>
You could do it with .base:
mytween = {x:10, time:1, etc}
Tweener.addTween(myobj, {base:mytween, time:0});
With the second point - I agree. I don't think there's any better/simple
way to do it though. Because Tweener has to go through some verification
for the on* functions and whether it's an special property or not, it's
not just a case of looping through the properties and applying them
immediately.
In any case, Tweener kind of "understands" it's a immediate change if
time is 0 so it bypasses some unnecessary code so other than the slight
syntactical inadequacy, I don't think there's a lot of trouble created
by using it. A separate function could be used to set the values (if you
don't use any special property) in a much cleaner way though, but I bet
that'd work better as part of your application.
Zeh
More information about the Tweener
mailing list