One of the easy things to do in Flash is tween but it never hurts to make an easy thing easier and that’s exactly what Grant Skin…errr…my bad…gSkinner (hehe) has done. So, maybe it doesn’t suit you, heck…might not suit me all the time, but I would say it is at least worth a look.
First off…go get it: “https://gskinner.com/libraries/gtween/”:https://gskinner.com/libraries/gtween/.
Second…read about it: “https://www.gskinner.com/blog/archives/2008/08/gtween_a_new_tw.html”:https://www.gskinner.com/blog/archives/2008/08/gtween_a_new_tw.html.
Third…use it.
Wait…guess I do have to review this at some point so let’s consider this the fourth bullet.
**Things I like**:
* 1 class file. No wondering what classes to use or where they are. It is literally only com.gskinner.motion.GTween. That’s it.
* Easy tweening: _new GTween(someObject, speed, {x: Math.random()*100});_. That isn’t a very useful tween but as you see it is pretty quick to tween.
* Easy tweening of multiple properties: _new GTween(someObject, speed, {x: Math.random()*100, y: Math.random()*100, width: someObject.width*.5});_. x, y, and width will all tween at once.
**Things I LOVE**:
* Chaining tweens:
_var tween:GTween = new GTween(someObject, speed, {x: Math.random()*100});_
_var otherTween:GTween = new GTween(anotherObject, speed, {x: Math.random()*100});_
_tween.addChild(otherTween);_
You can even set _otherTween.delay_ and have the second tween wait a few seconds, or whatever, befor it begins.
* When fading an object you can set the _autoHide_ tween property to true which will hide the object once the _alpha_ is 0. That’s a simple one but I hate leaving objects visible when alpha is 0 and it gets redundant to keep adding listeners on alpha tweens just to know when it is done.
* Events, events, events! It is completely event driven so you can monitor tween progress, completion, etc.
I could probably go on but I’d probably just repeat “Grant’s blog post”:https://www.gskinner.com/blog/archives/2008/08/gtween_a_new_tw.html.
**Things I want to see**:
* The first property expects an object. I’d like to see it accept an object OR an array of objects.
_new GTween([someObject, anotherObject], speed, {x: Math.random()*100});_
That would tween both of the objects to do the same thing. Right now I have to use two separate lines. It isn’t a terrible thing but a simple fix.
**Bugs**:
I really haven’t nailed down any bugs I’ve found but I also have only hit a couple snags. The only one I really noticed was with multiple objects tweening at once across different parents. Meaning, tweening objects in one MovieClip while simultaneously tweening other items. But…again…I never tracked it down so this could’ve been a bug in the rest of the code. If I find out the bug I noticed was a GTween bug…I’ll be sure to blog any fixes I find.
For now, grab it and enjoy.