ChainedTweener class

April 20, 2008

As i wrote in my previous post : BaseTweener class, ive made a class that extends the BaseTweener class to show an example of the usability of making an extensible tweener class.

So in this ChainedTweener class i’m gonna extend the BaseTweener class and make it execute tweenings in a cool easy chained way, so to have a glimpse of how this class can be used here’s an example :

var tweener:ChainedTweener = new ChainedTweener(_targetSprite, new Array("x","y")) ;
tweener = tweener.chainedTweenTo(new Array(100,200)).chainedTweenTo(new Array(50,300)).chainedTweenTo(new Array(1,10))

this will make a sequence of tweenings that will execute one after another, the benefits of this method is that you don’t have to worry about calculating delays to execute a sequence of tweenings anymore, and this class has the same functionalities as the BaseTweening class since this extends that.

Is there more examples of this ?

Off course, here’s a page of an example with the Document class code. In this example i’ve set the loop property of the ChainedTweener object to true, this makes the sequence of tweenings get inverted at its end. see here.

Explain more, how this exactly works and what can be done more ?

Actually what this class does is when the methods chainedTweenTo or chainedTweenFromTo are called, the tweener object creates a clone of itself, calculates the delay in function of how much tweening to go before he can fire, then pushes the clone into a static array, then the clone just pushed executes his tweening.

Also i’ve created a ChainedTweenerEvent class the contains the different events needed to listen to the chained tweenings. this class adds to the BaseTweener events a bunch of chainedTweener events that are fired when the chainedTweenTo and chainedTweenFromTo methods are used. Cool animations can happen when using the yoyo and the loop properties too.

So what can done more? well i plan to add the feature of defining sequences, store them , than call them whenever you need them, yeah , that’s definitely in my 2 do list.

Can you rapidly show me how did you extend the BaseTweener class and made this class out of it ?

yes, here’s the ChainedTweener actionscript file, see here.

Ok, i want to download this class :)

There you go, this archive file contains examples files + source files (ChainedTweener.as + ChianedTweenerEvent.as), download here (this has the file extension .jpeg but it’s a .rar file, i had to do that in order to host it here, please click : saveTargetAs or SaveLinkAs then when finished downloading change it’s extension to .rar, sorry for the extra work you have to do, i’ll be fixing that soon).

Advertisement

3 Responses to “ChainedTweener class”


  1. [...] extensible, and to show the usefulness of this extensibility i decided to make a cool inherited ChainedTweener class which works in a similar way to the JQuery chaining logic to make chained tweening (cool [...]

  2. Will Carroll Says:

    Great tutorial!

    Thanks


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.