I’ve just landed a neat summer job designing interactive content for the kiosks at a science museum. I couldn’t be happier, and I couldn’t be busier.
I decided yesterday to stop animating things the traditional ActionScript way– plotting the next point of an animation, and then moving the object to the point– in favor of using the new Tween system. I have to say, it’s really nice.
But if I’m not mistaken, a Tween can only act on a single property at a time. That makes sense, but sometimes I intend to Tween two properties of the same object at once, and I end up making two very similar Tweens. (Tweening scaleX and scaleY, or instance.) And because all sorts of properties in AS3 now range from 0 to 1, including alpha and the ColorTransform multipliers, it might be advantageous to use a hybrid strategy:
var drive:Number;
var dTween:Tween = new Tween(this, "drive", None.easeNone, 0, 1, 1000);
dTween.addEventListener(TweenEvent.MOTION_CHANGE, update, false, 0, true);
function update(twe:TweenEvent):void {
alpha = drive;
transform.colorTransform.redMultiplier = drive/2;
x += drive;
}
The tween only changes a single property, but while the tween occurs, other properties’ values change based on the tweened property. This allows one tween to do the work of several, with the only overhead being the [FONT=“Courier New”]update[/FONT] function.
Has anyone else tried this?