Thursday, July 19, 2007

Beauty of Tweening with Tween & TransitionManager class

Yes!!! Its true that you can tween any object on the stage without actually applying tweening in the timeline & its amazing.

I am pasting a small code snippet below for a quick reference, which generates a bounce effect for a movie clip placed on the stage.

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

new Tween(mcBall, "_y", Bounce.easeOut, 0, Stage.height-50, 3, true);

Parameters Explained:
1. "mcBall" is the movie clip placed on the stage
2. This parameter tells the constructor that what property will change in case of tweening. "_y" means the y position of the movie clip has to be changed.
3. The effect.
4. Starting y position.
5. End y position.
6. Duration of the tween.
7. Boolean Value related to the duration parameter, which indicates to use seconds if true, or frames if false.

The Tween and TransitionManager classes are available only in ActionScript 2.0, but these classes are available in both Flash Basic 8 and Flash Professional 8.

No comments: