This code example uses two
mx.transitions.Tween class only, and the second
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.
For information on working with packages, see
on page
499.
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
Using similar code, you set the
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
transparent in three seconds. To make the symbol fade out more quickly, change the
duration parameter from
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
on page
471.
statements. The first statement imports the
import
"Working with filter packages" on page
property to fade instances in and out, instead of the
_alpha
ball_mc
to
or
.
3
1
2
About the Tween and TransitionManager classes
statement uses the wildcard (
import
"Working with filter packages"
fades from 100% visible to completely
"About animation and frame rate"
)
*
499.
_x
491
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?