I have a timer counting up in as3. I am trying to simulate a clock counting up from 07:30 to 12:00. The functionality of the counting is working. How would i set an initial start value and a stop value?
Here is my code:
var timer:Timer = new Timer(100, 50);
timer.start();
timer.addEventListener(TimerEvent.TIMER, timerTickHandler);
var timerCount:int = 10;
function timerTickHandler(Event:TimerEvent):void
{
timerCount += 10000;
toTimeCode(timerCount);
}
function toTimeCode(milliseconds:int) : void
{
//creating a date object using the elapsed milliseconds
var time:Date = new Date(milliseconds);
//define minutes/seconds/mseconds
var minutes:String = String(time.minutes);
var seconds:String = String(time.seconds);
var miliseconds:String = String(Math.round(time.milliseconds)/100);
//add zero if neccecary, for example: 2:3.5 becomes 02:03.5
minutes = (minutes.length != 2) ? '0'+minutes : minutes;
seconds = (seconds.length != 2) ? '0'+seconds : seconds;
//display elapsed time on in a textfield on stage
timer_txt.text = minutes + ":" + seconds;
}