O'Reilly logo

Introducing Starling by Thibault Imbert

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Tweens

Starling also supports tweening and comes with its own tweening engine, supporting most of the most common equations, illustrated in Figure 1-56.

In this code, we apply a tween to the x and y properties of our text field with a bounce effect:

// create a Tween object
var t:Tween = new Tween(bmpFontTF, 4, Transitions.EASE_IN_OUT_BOUNCE);

// move the object position
t.moveTo(bmpFontTF.x+300, bmpFontTF.y);

// add it to the Juggler
Starling.juggler.add(t);
Easing equations available in Starling (figure courtesy of sparrow-framework.org)

Figure 1-56. Easing equations available in Starling (figure courtesy of sparrow-framework.org)

Here is the list of APIs available on a Tween object:

animate

Animates the property of an object to a target value. You can call this method multiple times on one tween.

complete

End the tween when called.

currentTime

The current timing for the tween.

delay

The delay before the tween is started.

fadeTo

Animates the alpha property of an object to a target value. You can call this method multiple times on one tween.

isComplete

Informs if the tweening is complete or not.

moveTo

Animates the x and y properties of an object simultaneously.

onComplete

Reference to the callback called when tween is complete.

onCompleteArgs

Parameters to be passed to the the callback when tween is complete.

onStart

Reference to the callback called when tween starts.

onStartArgs

Parameters to be passed to the the callback when tween starts.

onUpdate

Reference to the callback called when ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required