492
Animation, Filters, and Drawings
Instead of using seconds, you can fade the symbol over a few frames. To set the duration in
frames instead of seconds in the Tween class, you change the final parameter,
useSeconds
,
from
true
to
false
. When you set the parameter to
true
, you tell Flash that the specified
duration is in seconds. If you set the parameter to
false
, the duration is the number of
frames you want to use for the tween. The next procedure shows how to set a tween to frames
instead of seconds.
To set a duration of frames instead of seconds:
1.
Create a new document, and call it
framesTween.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, 24, false);
This code fades out the
ball_mc
instance using the
Strong.easeIn
easing method.
Instead of fading the instance for three seconds, it fades the instance across 24 frames.
5.
Select Control > Test Movie to see the animation.
Wait a moment, then the instance fades out across 24 frames.
6.
Return to the authoring environment and open the Property inspector.
7.
Change the document’s frame rate to
24
fps.
If you increase the frame rate of your FLA file, you see the instance fade out sooner. For
information on animation and frame rate, see
“About animation and frame rate”
on page 471
.
Using frames instead of seconds offers more flexibility, but remember that the duration relates
to the frame rate of the current Flash document. If your Flash document uses a frame rate of
12 frames per second (fps), the previous code snippet fades the instance over two seconds
(24 frames/12 fps = 2 seconds). However, if your frame rate is 24 fps, the same code fades the
instance over one second (24 frames/24 fps = 1 second). If you use frames to measure
duration, you can significantly change the speed of your animation when you change the
document’s frame rate, without modifying your ActionScript.
The Tween class has several more useful features. For example, you can write an event handler
that triggers when the animation completes, as the next procedure shows.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...