We will start from the Drawing meters and gauges recipe in Chapter 4, Drawing Different Types of Graphs and we will animate it using the TweenLite
animation engine.
Get the code from the recipe previously mentioned and we will modify it to make it animated.
The first step would be to go to http://www.greensock.com and download the ActionScript 3 library.
Add the
greensock.swc
file to thelib
folder in the project.In FlashDevelop, right-click on
greensock.swc
and choose Add To Library.We are now ready to use
TweenLite
in our code. InMeter.as
, we will setalpha
to zero so that we can animate it.To do so we will add the
animateIn
and thearrowTo
functions:public function animateIn():void { TweenLite.to(this, 0.5, { alpha:1, delay:1 } ); TweenLite.delayedCall(1.5, arrowTo, [percent]); } public function arrowTo(newPercent:Number):void { TweenLite.to(_arrow, 1, { rotation: _baseArrowRotation + 140 * newPercent, ease:Bounce.easeOut } ); }
We will...