Tween.onMotionFinished

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX 2004.

Usage

tweenInstance.onMotionFinished = function() {
    // ...
};

Description

Event handler; invoked when the animation reaches the end of its duration. Handling this event allows your code to react at the point at which the tweened animation is finished.

Example

In the following example, a tween is applied to the img1_mc movie clip. When the tween reaches the end of its animation, it invokes the onMotionFinished event handler which calls the Tween.yoyo()method. The tween is therefore able to complete its animation before the Tween.yoyo() method is called to reverse the animation. A movie clip instance named img1_mc is required on the Stage for this example:

import mx.transitions.Tween;
var myTween:Tween = new Tween(img1_mc, "_x", mx.transitions.easing.Elastic.easeOut,0, Stage.width-img1_mc._width, 3, true);
myTween.FPS = 30;
myTween.onMotionFinished = function() {
    myTween.yoyo();
};