- Code: Select all
// Import tween classes
import mx.transitions.Tween;
import mx.transitions.easing.*;
// make a rectangle/button on stage, and give it instance name "rectangle_obj"
var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Elastic.easeOut, 0, 360, 3, true);
//Property use for the Tween class -------------------
var theDuration:Number = rotationTween.duration;
trace("Duration = "+theDuration);
var myFinish:Number = rotationTween.finish;
trace(myFinish);
rotationTween.FPS = 25;
var myFPS2:Number = rotationTween.FPS;
trace("rotationTween.FPS:" + myFPS2);
var myPosition:Number = rotationTween.position;
trace("myPosition " + rotationTween);
//Event handler use for the Tween class ---------------
rotationTween.onMotionFinished = function() {
rotationTween.yoyo();
/*
More Methods for the Tween class -
Tween.yoyo() | Instructs the tweened animation to continue from its current value to a new value.
Tween.fforward() | Forwards the tweened animation directly to the end of the animation.
Tween.nextFrame() | Forwards the tweened animation to the next frame.
Tween.prevFrame() | Directs the tweened animation to the frame previous to the current frame.
Tween.resume() | Resumes a tweened animation from its stopped point in the animation.
Tween.rewind() | Rewinds a tweened animation to the beginning of the tweened animation.
Tween.start() | Starts the tweened animation from the beginning.
Tween.stop() | Stops the tweened animation at its current position.
Tween.toString() | Returns the class name, "[Tween]".
Tween.yoyo() | Instructs the tweened animation to play in reverse from its last direction of tweened property increments.
*/
}
rotationTween.onMotionResumed = function() {
trace("onMotionResumed Called...")
// do your stuff here
}
rotationTween.onMotionStarted = function() {
trace("onMotionStarted Called...")
// do your stuff here
}
rotationTween.onMotionStopped = function() {
trace("onMotionStopped Called...")
// do your stuff here
}
// press ctrl+enter to test the movie
More Easing Classes
var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Back.easeOut, 0, 360, 3, true);
var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Bounce.easeOut, 0, 360, 3, true);
var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Elastic.easeOut, 0, 360, 3, true);
var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Regular.easeOut, 0, 360, 3, true);
var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Strong.easeOut, 0, 360, 3, true);
var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", None.easeOut, 0, 360, 3, true);
More Easing Methods
var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Back.easeIn, 0, 360, 3, true);
easeOut
easeInOut
easeNone
You can apply the easing methods only to the following components:
Accordion, ComboBox, DataGrid, List, Menu, and Tree. Each component uses the easing methods to allow different customizations. For example, the Accordion, ComboBox, and Tree components let you select an easing class to use for their respective open and close animations. In contrast, the Menu component lets you define only the number of milliseconds that the animation lasts.
