494
Animation, Filters, and Drawings
After the initial tween finishes, the
ball_mc
movie clip tweens back to its original position at
0 pixels. The following snippet (edited for brevity) shows the function prototype for the
continueTo()
method:
function continueTo(finish:Number, duration:Number):Void {
/* omitted to save space. */
}
Only two arguments pass to the
continueTo()
method, instead of the seven arguments for
the Tween constructor method, as the following snippet shows:
function Tween (obj, prop, func, begin, finish, duration, useSeconds) {
/* omitted to save space. */
}
The five parameters that aren’t required by the
continueTo()
method (
obj
,
prop
,
func
,
begin
, and
useSeconds
) use the arguments that you defined earlier in the call to the Tween
class. When you call the
continueTo()
method, you assume that the
obj
,
prop
,
func
(easing
type), and
useSeconds
arguments are the same as in the earlier call to the Tween class. The
continueTo()
method uses the
finish
value from the call to the Tween class, instead of
specifying a value for the
begin
argument, as the following ActionScript shows:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var ball_tween:Object = new Tween(ball_mc, "_x", Regular.easeIn, 0, 300, 3,
true);
ball_tween.onMotionFinished = function() {
ball_tween.continueTo(0, 3);
};
This code moves the
ball_mc
instance along the
x-
axis from 0 pixels to 300 pixels in three
seconds. After the animation finishes, the
onMotionFinished
event handler is triggered and
calls the
continueTo()
method. The
continueTo()
method tells the target object
(
ball_mc
) to proceed from its current position and animate for three seconds along the
x
-axis
to 0 pixels and to use the same easing method. You use the values specified in the call to the
Tween constructor method for any parameters that you don’t define in the
continueTo()
method. If you don’t specify a duration for the
continueTo()
method, it uses the duration
you specify in the call to the Tween constructor.
Creating animations that run continuously
You can make an animation continue moving back and forth along the
x
-axis without
stopping. The Tween class accommodates this kind of animation with the aptly named
yoyo()
method. The
yoyo()
method waits for the
onMotionFinished
event handler to
execute, and then it reverses the
begin
and
finish
parameters. The animation begins again,
as the following procedure demonstrates.
Содержание 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...