Anyone who checks this blog regularly will notice that I am forever tweaking, re-writing or updating my Tweeny class. This is an ultra simple tween engine that I’ve start developing that is very personalized for me and is aimed at providing the simplest and quickest way for me to add dynamic animation to an AS3 project. I’ve had a few hiccups recently, main because I’ve been getting my head around the best way to write and organize Tweeny.
For a job I’m working on at the moment I’ve needed to create several different types of animations, some are simples slides, others where 100+ objects bouncing down on to the stage. I used Tweeny for these so that I could create the effect I wanted but without having 100 tweens on the timeline, what if I needed to change the speed or position, I wasn’t going to sit and adjust 100 guide paths. (I haven’t started using my CS4 install yet but hopefully that will all be a thing of the past anyway).
So I needed to add some additional functionality to Tweeny for these new animations.
- Animate multiple objects and then listen for a COMPLETE event once they are all finished.
- Now Tweeny 0.9 dispatches a COMPLETE event each time all tweens are finished and Tweeny is deactivating. All I have to do now is register for the event using Tweeny.addEventListener(Event.COMPLETE, completeHandler) and then use removeEventListener() in the handler function so that I only listen for this event once. Otherwise the next time I tween something, Tweeny will still dispatch the COMPLETE event even if it’s a different item. This is a faster way of implementing a TweenyGroup. I was thinking about creating a TweenyGroup class but what’s the point when I can achieve the same effect with less code. - Pause every tween.
- Now Tweeny 0.9 has to new methods. pauseAllTweens() and resumeAllTweens(). These do exactly what they say on the tin. The stop the update function from being called until resumeAllTweens() is called to resume. (Maybe I should add a completeAllTweens() and stopAllTweens() to completely remove all tweens from Tweeny. One will force the tween to the end and call any onComplete functions that have been set, the other will simple stop all the tweens in their tracks and remove them from the tweens array.
Visit the Tweeny page for more info and a link to download the latest zip from my code.google account.