Skip to main content
Known Participant
February 6, 2014
Question

Counter

  • February 6, 2014
  • 1 reply
  • 377 views

Hello all,

I want to create a number counter using AS3 and a dynamic text box (myTextBox_txt). I want to be able to set the starting number (e.g. 15986) and have it increment quickly to another set number.

I've been out of scripting for a while and can't think how to do it!

Cheers

Nick

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
February 6, 2014

what causes the textfield to increment? 

the passage of time? if so, use a timer.

user visits?  if so, you'll need to use, at least, one server-side file.

NickGGAuthor
Known Participant
February 6, 2014

it will be over time, what would be the coding to do this with a timer?

kglad
Community Expert
Community Expert
February 6, 2014

var t:Timer=new Timer(1000,0);  // assumming you want to update about once per second (=1000 ms)

t.addEventListener(TimerEvent.TIMER,f);

t.start();

function f(e:TimerEvent):void{

tf.text=String(t.currentCount);  // where tf is your textfield reference

}