RSS Follow me on Facebook Follow me on Twitter
to home page

Tween Manager Class in AS3

TweenManager is ActionScript3 class that helps you to animate your objects in flash. You don't need to create timeline type animations, because you can control every property of the object. Also it helps you to create a sequence by different animations/events. In the examples below I'll show you how to use the manager to solve different problems during your daily flash work.

TweenManager.tween method
As a first parameter of this function you can put an object with property that you want to tween. For example you can pass MovieClip and change the "x" property, or TextField and change the "alpha" property. It doesn't matter what kind of object it is. That means that you can use your own object and change your own property. I'll give an example of this later. The code below changes the "x" property of MovieClip "exampleMovie":

The second parameter (tweenObj) is an object that contains other objects (xTween). The other object could have the following properties:
• start - the initial value
• end - the end value
• steps - duration of the tween (in frames)
• after - number of frames before staring of the tween
• mtd - method of the tween. All the methods are defined in the TweenType class
• callback - function to call after tween ends



Example of TweenManager.tween. You can change the "mtd" property of the tween object using the combobox. Download the source files from here.Here is an example how to use TweenManager with your own object and property. The source can be found here.

And the result is:


TweenManager.alpha method
Basically this function uses TweenManager.tween to change the alpha property. Because I'm changing the alpha very often I just wrote this simple method. Download the example to check how it works.

TweenManager.gotoFrame method
With this method we can control the timeline based animations. gotoFrame function accepts two parameters. The first one, the same as tween method, is the object for tweening. The second one is an object with parameters:
• start - initial frame
• stop - end frame
• after - number of frames before starting of the tween
• callback - function to call after tween ends



example's source

TweenManager.stop method
If you want to stop the tween just pass the object and the type of the tween.
example:


TweenManager.color method
If you have a filled shape you can simply change the color of it using TweenManager.color. You can download the example below from here.




Your name: add your comment here
Email:
Tween Manager Class in AS3 Leave this field blank if you don't want to receive notifications about this article.
Website:
Tween Manager Class in AS3 Will be published below your name. Should start with 'http://'.
Comment:
5 + 5 =
send