Friday, 24 June 2011

Animate dynamic text fields in AS3

Here is a quick example of how to animate a dynamic text field to a specific time in Actionscript 3. I will be animating the numbers from 1 – 100 in ten seconds. I have used the TweenNano class which can be downloaded from To achieve this effect I have passed an object to the target of the method and assigned a target number to the startNumber property of the object. Then I use the onUpdate property to call the updateHandler function every time the tween’s time is updated. This means that every time the tween gets fired you will see the dynamic text number increase until the target number and the duration time has been reached.

import com.greensock.TweenNano;

var obj:Object = new Object();
obj.startNumber = 0;

var targetNumber:uint = 100;, 10, { startNumber: targetNumber, onUpdate:updateHandler});

function updateHandler():void{
    output_txt.text = uint(obj.num).toString();


  COPYRIGHT © 2014 · ILIKE2FLASH · Theme by Ourblogtemplates

Back to TOP