About the Tween and TransitionManager classes 491
This code example uses two import statements. The first statement imports the
mx.transitions.Tween class only, and the second
import statement uses the wildcard (*)
shortcut to import each of the six easing classes by using a single line of code. The second
statement imports an entire package of classes.
5. Select Control > Test Movie to see the animation.
Flash documentation defines package as directories that contain one or more class files and
that reside in a designated classpath directory. In this case, the package resides in the
C:\Program Files\Macromedia\Flash 8\language\First Run\Classes\mx\transitions\easing
folder (Windows), or HD:Applications:Macromedia Flash 8:First
Run:Classes:mx:transitions:easing (Macintosh). You might agree that importing an entire
package is much better than having to import the six classes separately. Instead of referring to
the mx.transitions.Tween class, your ActionScript directly refers to the Tween class. Likewise,
instead of using the fully qualified class name for the easing classes,
mx.transitions.easing.Elastic.easeOut for example, you can type Elastic.easeOut in your
ActionScript code. For more information, see “Working with filter packages” on page 499.
Using similar code, you set the
_alpha property to fade instances in and out, instead of the _x
property, as the next procedure shows.
To fade instances using the Tween class:
1. Create a new document, and call it fadeTween.fla.
2. Create a movie clip on the Stage.
3. Select the movie clip instance, and type ball_mc into the Instance Name text box in the
Property inspector.
4. Select Frame 1 of the Timeline and add the following code in the Actions panel:
import mx.transitions.Tween;
import mx.transitions.easing.*;
new Tween(ball_mc, "_alpha", Strong.easeIn, 100, 0, 3, true);
Instead of moving around the Stage, now ball_mc fades from 100% visible to completely
transparent in three seconds. To make the symbol fade out more quickly, change the
duration parameter from
3 to 1 or 2.
5. Select Control > Test Movie to see the animation.
If you change the document’s frame rate, the animation appears to play more smoothly.
For information on animation and frame rate, see “About animation and frame rate”
on page 471.
NOTE
For information on working with packages, see “Working with filter packages”
on page 499.