Jump to content

AS3 Timer


astralaaron

Recommended Posts

I am trying to count seconds / milliseconds and display it like 1.11.21.31.41.51.61.71.81.92.02.1etc.... 10.1etc..20.120.2because I am trying to clock how fast someone is typing but seconds are not a small enough unit to measure with. thanks for any help

Link to comment
Share on other sites

This is probably the dumbest of all of the ways you could possibly make this happen but it seems to be working so farvar timer:Timer = new Timer(100, 6000);timer.addEventListener(TimerEvent.TIMER, countup);timer.start();function countup(event:TimerEvent) {var totalcount:int = timer.currentCount; if(totalcount < 10) { myText.text = String(totalcount); } else if ((totalcount > 10) && (totalcount < 100)) { myText.text = String(totalcount).substr(0,1) + "." + String(totalcount).substr(1,1); } else if ((totalcount > 100) && (totalcount < 1000)) { myText.text = String(totalcount).substr(0,2) + "." + String(totalcount).substr(2,2); } else if ((totalcount > 1000) && (totalcount < 10000)) { myText.text = String(totalcount).substr(0,3) + "." + String(totalcount).substr(3,3); } else if ((totalcount > 10000) && (totalcount < 100000)) { myText.text = String(totalcount).substr(0,4) + "." + String(totalcount).substr(4,4); }}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...