AddThis Social Bookmark Button
 Dynamic tweening with the Tween and Easing class (part 3)

Methods, properties and events of the Tween class

You will find below a list of useful methods, properties and events that will give you even more control on your dynamic tweenings.

Method
Description
Tween.continueTo(finish,duration) 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.

Property
Description
Tween.duration The duration of the tweened animation in frames or seconds. Read-only.
Tween.finish The last tweened value for the end of the tweened animation. Read-only.
Tween.FPS The number of frames per second of the tweened animation.
Tween.position The current value of the target movie clip's property being tweened. Read-only.
Tween.timeTween.time The current time within the duration of the animation. Read-only.

Event
Description
Tween.onMotionChanged Event handler; invoked with each change in the tweened object's property that is being animated.
Tween.onMotionFinished Event handler; invoked when the Tween object finishes its animation.
Tween.onMotionResumed Event handler; invoked when the Tween.resume() method is called, causing the tweened animation to resume.
Tween.onMotionStarted Event handler; invoked when the Tween.start() method is called, causing the tweened animation to start.
Tween.onMotionStopped Event handler; invoked when the Tween.stop() method is called, causing the tweened animation to stop.

Events are implemented as usual :

import mx.transitions.Tween;
import mx.transitions.easing.*;

playAnimation.onPress = function() {

this.enabled = false;

myTweeningX =
new Tween(hat, "_x",Bounce.easeOut, 33, 418, 2, true);
myTweeningY =
new Tween(hat, "_y",Bounce.easeIn, 34, 166, 2, true);

myTweeningX.
FPS = 40;
myTweeningY.
FPS = 40;

myTweeningX.onMotionFinished = function(){
playAnimation.enabled = true;
trace("X motion is finished");
// once the motion is finished we move the hat to x=0 over 2 seconds
myTweeningX.continueTo(0,2)
}
};

Don't hesitate to experiment, the possibilities are endless.


Good luck :)




download source files download source files
AddThis Social Bookmark Button
If you think this page is providing useful information, don't hesitate to leave a comment.
flashvalley
 
Copyright ©2006-2008 flashvalley.com - All rights reserved