Thursday, October 23, 2008

Tweening in AS3

This uses the built-in Tween and easing classes. I don't like juggling external classes from 3rd parties if I can help it.

//Tweens wont work without these:
import fl.transitions.Tween;
import fl.transitions.easing.*;

//This creates the tween
var myTween:Tween;
myTween = new Tween(movieclip, "x", Elastic.easeInOut, start, end, 3, true);

The stuff in parentheses...
1. The movieClip to tween
2. Property to tween
3. Type of tween (see help: fl.transitions.easing). Here are the options:
First item: Back, Bounce, Elastic, None, Regular, Strong
Second Item aftyer period: easeIn, easeOut, easeInOut
4. Start value
5. End value
6. true=Measure in seconds, false=Measure in milliseconds.

No comments: