1 post tagged “easing”
At first I was seduced by Tweener's method of making all tweening activity global class functions. After all why would you want two tweens on any singular parameter at the same time anyway? By making class functions, it's easy to prevent it from happening. But upon reflection I think a Tween deserves to be a separate entity that stands on it's own. Robert Penners foundational Programming Flash advocated a Tween be a separate object as well.
There's really not much code in Tweener. It's no insurmountable task to just reproduce...
I much prefer the method devised by adobe for it's Flex 2 mx.effect classes.
But they only work on UIComponents and subclasses, which are flex components, basically. So, for example, mx.effects.Move doesn't work on a Sprite. Pity...there's no reason it shouldn't, from what I see.
I can reimplement most of what I want from their already great design, only to be used with Sprites. That's my plan. No need to reinvent the great architecture. Just a need to implement with Sprites...I'll reuse everything I can, like the built in easing classes and the Tween() class (internally).
By peeling tweens off of Sprites and letting them stand as first class object citizens, we allow ourselves to reuse the same tween on several objects. We can also alter small parts of a tween and apply, over and over, to the same or different Sprites. (We could actually Tween the values of the Tween! boggling!...haha). Also a standalone object like mx.effects.Move incorporates methods like pause(), reverse(), playInReverse() (sorta), and many others that aren't handled as elegantly with Tweener's global function system.
Say I want to slide a button to the right on rollover, and back to the left on roll off. I can instantiate one Tween and then just play it forward and backwards. With each rollover/rolloff, I can reuse the same object I only made once. If I call Tweener.addTween() i'm throwing one-offs each time.
There's also a major design flaw in Tweener as I see it. All it's tween callbacks remain old-school actionscript 2.0 style. You explicitly define singular functions for each different callback....DUDE, where's the EventDispatcher love? AS3.0 loves EventDispatchers and you should too....they are super flexible and they really help design the interaction of objects that must be aware of each other's current state. Plus their functionality is built in! just grab and reuse.
fleh. </rant>