Hi, I'm trying to get my stopwatch to work and convert the milliseconds into minutes and seconds but the output text is only showing 00:00.
Here's the code
Actionscript Code:
var myTimer:Timer=new Timer(1000, 0);
myTimer.addEventListener(TimerEvent.TIMER, stopWatch);
start_btn.addEventListener(MouseEvent.CLICK, startClock);
function stopWatch(event:TimerEvent):void {
var now:Timer = new Timer(1000, 0);
var timeElapsed:Number = myTimer.currentCount + now.currentCount;
var seconds:Number = Math.floor(timeElapsed / 1000);
var minutes:Number = Math.floor(seconds / 60);
seconds %= 60;
minutes %= 60;
var sec:String = seconds.toString();
var min:String = minutes.toString();
if(sec.length < 2){
sec = "0" + sec;
}
if(min.length < 2){
min = "0" + min;
}
var time:String = min + ":" + sec;
//////////////////////////////
myText_txt.text=time;
trace(time)
}
function startClock(event:MouseEvent):void {
myTimer.start();
}
Any suggestions please?