"Animation is the new Tween": New effects APIs in Gumbo +
I haven't really been following "Gumbo" (Flex 4) all this while, but today I came across these excellent presentation slides (PDF) from Chet Haase's talk at the Devoxx conference titled Effect-ive Flex. It appears that the entire effects framework has been rethought from the ground up for this release. The most striking change comes in the form of the new Animation class, which replaces good ol' Tween as the foundation for all of the high-level effects.
Here's a small example from the presentation:
// Moves object foo from x=0 to x=100 over a half-second
var anim:Animation = new Animation(0, 100, 500);
anim.addEventListener(AnimationEvent.ANIMATION_UPDATE, updater);
anim.play();
private function updater(event:AnimationEvent):void {
foo.x = event.value;
}
The above code moves the object foo horizontally (x) from 0 px. to 100 px. over 500 milliseconds.
The same code in Flex 3 would look like this:
// Moves object foo from x=0 to x=100 over a half-second
var tween:Tween = new Tween(this, 0, 100, 500);
private function onTweenUpdate(value:Number):void {
foo.x = value;
}
private function onTweenEnd(value:Number):void {
onTweenUpdate(value);
}
There are at least 2 reasons why the new Animation class is better than Tween:
- No more auto-play on construction (call
play) - Only event listeners, no callbacks
Aside from that, it also has some neat features, like the ability to specify easers, repitition, and a new reverse behavior.
I always found the Tween class rather clumsy, so very "AS2", but never thought it worth a rewrite (if it ain't broke, don't fix it!). It's good to see these new changes. If you're into effects and transitions in Flex, you should spare 5 minutes to go through Chet's slides (PDF). He's even made a Flex-less (pure AS3) version of the new animation engine available on his site under the name "Flexy".
[...] Manish Jethani noticed a PDF of one of Chet Haase’s talks about animation and the Flex framework. It was cool to see it, especially after seeing Lee blog about choosing a Flash tweening library. As you can see from Lee’s post, there are a ton of great tweening libraries for ActionScript 3. And traditionally, Flex has been a bit behind in the animation department. One conversation with Chet will make you realize that’s not going to be true in Flex 4. We have some awesome stuff in store, so if you’re interested in creating filthy rich Flex apps, make sure to find Chet and talk to him. [...]