User Guide

Using the Tween class 1313
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);
Tween class parameters
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 objects property
values. See About easing classes and methods” on page 1314
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).
Tween.onMotionResumed Event handler; invoked when the Tween.resume() method is
called, causing the tweened animation to resume.
Tween.onMotionStarted Event handler; invoked when the Tween.start() method is
called, causing the tweened animation to start.
Tween.onMotionStopped Event handler; invoked when the Tween.stop() method is
called, causing the tweened animation to stop.
Event Description