Working with Tween Engines

Tweening

The Tween Class inside flash lets us create simple animations easily in ActionScript by specifying the starting and ending points of an object animation positions. It can actually be used to tween any property of any object.
By the term tween we mean here the gradual increase or decrease of the value of a property which can bring about an animation. This could be the increase of transparency, the decrease in width, or the movement from left to right of any object.

The Tween Class is not included by default in a Flash movie and must be imported before it can be used, Adobe did this to ensure to help making SWF files smaller so that the Class is included only in movies that require it. To import this class you must use the import directive at the beginning before you start your actual code. Here is the code you need:

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;

The Tween Class must be used through an instance of it (using a variable).
When instantiating the Tween Class you must provide the parameters required by the TWeen Class.

 
var
myTween : Tween = new Tween ( object , "property , EasingType , begin , end , duration , time ) ;
 
var
name : data type = initial value ( 1 , 2 , 3 , 4 , 5 , 6 , Boolean ) ;


var rectTween:Tween =new Tween ( (rectangle_mc, "x", Strong.easeOut, 0 , 300, 3, true)

Ease Classes (to define parameter 3, Ease Type)

Regular: the motion speed will gradually increase or decrease in speed as specified by the easing method.
Bounce: the motion will bounce back a few steps when it reaches the end position before settling at it.
Back: the motion will go beyond the end position before bouncing back into it.
Elastic: a mixture of Bounce and Back effects combined.
Strong: a more emphasized Regular effect.
None: no easing, the motion will not speed up and will reflect a continuous motion across space and time.

Ease Methods

Each of the previous functions must be then be configured using one of the easing methods to determine at which part of the tween it shall apply the effect, i.e. at the start of it, the end of it, both, or none:

easeIn
: The tween effect is applied to the start of the animation.
easeOut: The tween effect is applied to the end of the animation.
easeInOut: the tween effect is applied to the start and end of the animation.
easeNone: no tweening effect is applied, to be used with the None tween function.