TextField counter

nth1971
nth1971 used Ask the Experts™
on
Hi could anyone advise... I need to display a text field that animates a number ticker 1 to say 500.. doesnt seen to work anyone got any ideas? thanks

var myText:TextField = new TextField();
addChild(myText);

for (var i:Number=1; i<=150; i++)

            {
            myText.text = String(i);
            }
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2011
Commented:
You need to use a Timer class

var myText:TextField = new TextField();
addChild(myText);
var i:uint = 1;
var myTimer:Timer = new Timer(100, 500);
myTimer.addEventListener(TimerEvent.TIMER, function(event:TimerEvent):void {
     myText.text = String(i++);    
});
myTimer.start();

Author

Commented:
Cheers!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial