ActionScript 2.0 Components Language Reference |
|
|
|
| Tween class > Using the Tween class | |||
To use the methods and properties of the Tween class, you use the new operator to create a new instance of the class. For example, to apply an instance of a tween to a movie clip object on the Stage called myMovieClip_mc, you use the following code to create a new instance of mx.transitions.Tween:
import mx.transitions.Tween; var myTween:Tween = new Tween(myMovieClip_mc, "_x", mx.transitions.easing.Elastic.easeOut, 0, 300, 3, true);
When you create a new instance of a Tween class, you pass several parameters. You must indicate the target movie clip object, what property of the movie clip the tween is to affect, the range over which the object is to be tweened, and an easing method to use to calculate the tweened property.
The constructor for the mx.transitions.Tween class has the following parameter names and types:
Tween(obj:Object,prop:String,func:Function,begin:Number,finish:Number,duration:Number,useSeconds:Boolean )
obj The movie clip object that the Tween instance targets.
prop A string name of a property in obj to which the values are to be tweened.
func The easing method that calculates an easing effect for the tweened object's property values. See About easing classes and methods
begin A number indicating the starting value of prop (the target object property to be tweened).
finish A number indicating the ending value of prop (the target object property to be tweened).
duration A number indicating the length of time of the tween motion. If omitted, the duration is set to infinity by default.
useSeconds A Boolean value indicating to use seconds if true or frames if false in relation to the value specified in the duration parameter.
When you create an instance of the Tween class, you use the func parameter to specify a function or method that provides an easing calculation. Flash provides five easing classes, each with three methods that indicate which part of the transitional motion to apply the easing effect to: at the beginning of the animation, the end, or both. In addition, a None easing class with an easeNone method is available for designating that no easing be used.
The following classes and components use the easing classes and methods:
The six easing calculation classes are described in the following table:
|
Easing Class |
Description |
|---|---|
|
Back |
Extends the animation once beyond the transition range at one or both ends to give the effect of being pulled back from beyond its range. |
|
Bounce |
Adds a bouncing effect within the transition range at one or both ends. The number of bounces relates to the duration--longer durations produce more bounces. |
|
Elastic |
Adds an elastic effect that falls outside the transition range at one or both ends. The amount of elasticity is unaffected by the duration. |
|
Regular |
Adds slower movement at one or both ends. This feature lets you add a speeding up effect, a slowing down effect, or both. |
|
Strong |
Adds slower movement at one or both ends. This effect is similar to the Regular easing class, but it's more pronounced. |
|
None |
Adds an equal movement from start to end without effects, slowing, or speeding up. This transition is also called a linear transition. |
These six easing calculation classes each have three easing methods, which indicate at what part of the animation to apply the easing effect. In addition, the None easing class has a fourth easing method: easeNone. The easing methods are described in the following table:
|
Method |
Description |
|---|---|
|
easeIn |
Provides the easing effect at the beginning of the transition. |
|
easeOut |
Provides the easing effect at the end of the transition. |
|
easeInOut |
Provides the easing effect at the beginning and end of the transition. |
|
easeNone |
Indicates no easing calculation is to be used. Provided only in the None easing class. |
|
|
|
|