Tweening with Tweensy – Properties and Colors
I’ve started using Tweensy after realising that TweenMax requires a license fee for commercial use. Though my personal use is seldom commercial, why learn a library that’s useless to me when I am doing commercial work?
Firstly, a big nod to Shane McCartney, who has done the hard work of creating this new tweening library.
A new library means learning a new syntax. As I go, I will post a few things that I learn along the road, since as yet, Tweensy is not that widespread:
A Simple Tween
To tween an object’s position you can use a static method, like TweenMax:
Tweensy.to(myDisplayObject, {x:300, y:100});
It will tween over half a second, unless you add a third parameter indicating the duration of time. This is very close to TweenMax. The static method produces a TweensyTimeline, or you could just create a new TweensyTimeline and add the various properties to it.
A Color Tween
To tween an object’s color, you can create a TweensyGroup and add a colorTransformTo call to it.
var tween:TweensyGroup = new TweensyGroup(); var color:ColorTransform = new ColorTransform(); color.color = 0xFF0000; tween.colorTransformTo(myDisplayObject, color);
A TweensyGroup I thought? I bet you can tween more than just one item simultaneously with that. And so you can:
Roll-over to trigger the tweens. Click outside when you’ve had enough! If for some odd reason you want the source then you can download it here.
A bit of API confusion
As yet, I’m not really clear what is the difference between a TweensyGroup and a TweensyTimeline. I’m sure it will become apparent. You can’t call TweensyTimeline.colorTransformTo though TweensyGroup.colorTransformTo returns a TweensyTimeline. My suspicion is that Shane spends longer at the chalk-face of creating his extremely impressive BitmapData effects than he does doing the dull-but-important job of ensuring that his API is clean and tidy. Alternatively, there may be a very good reason for the API decision, in which case I am extremely sorry for that supposition.
-
Miller J.
-
Shane Hoffa
-
alecmce
-
alecmce
-
Jackson Dunstan
-
alecmce
