View Full Version : 300000 Milliseconds to 5:00
dColumbus
March 9th, 2009, 12:55 AM
Hey there,
I've looked all over the web and I have not been able to wrap my head around converting milliseconds to a properly formated time.
I have a 5 minute countdown timer and I want to format the milliseconds into a proper time...
PLEASE help me out here!
TheCanadian
March 9th, 2009, 01:11 AM
var m:int = 300000;
var d:Date = new Date(m);
trace(d.getMinutes() + ":" + (d.getSeconds() < 10 ? "0" : "") + d.getSeconds()); //5:00
dColumbus
March 9th, 2009, 01:20 AM
Thanks for the reply, Canadian... but there seems to be some issue:
var m:int = int(clockCounter.repeatCount - clockCounter.currentCount);
var d:Date = new Date(m);
this.tfTimeDisplay.text = String( d.getMinutes() + ":" + (d.getSeconds() < 10 ? "0" : "") + d.getSeconds() ); //5:00
All I get is "0:00" ... it never changes.
TheCanadian
March 9th, 2009, 01:29 AM
You need to update it with the timer.
dColumbus
March 9th, 2009, 01:45 AM
That code is within the updateTimer function... all other things work.
TheCanadian
March 9th, 2009, 02:33 AM
Why are you using repeatCount and currentCount, they have nothing to do with milliseconds.
dColumbus
March 9th, 2009, 03:45 AM
Why are you using repeatCount and currentCount, they have nothing to do with milliseconds.
Those are variables. repeatCount is the total number of milliseconds (300000) and currentCount is where is that time the Timer currently is that. The code you gave me works fine in Flash, but not in Flex. The Date returns are always O in Flex.
TheCanadian
March 9th, 2009, 01:25 PM
I'm not a flex guy, but I don't reccomend having a timer run 300000 times and be called every millisecond.
dColumbus
March 9th, 2009, 06:27 PM
Well how else would I tell the timer to correctly count?
if (timeType == "seconds")
{
this.timeInSeconds = timeValue;
}
if (timeType == "minutes")
{
this.timeInSeconds = timeValue * 60;
}
clockCounter = new Timer(1000, this.timeInSeconds);
clockCounter.addEventListener(TimerEvent.TIMER, timeTick);
clockCounter.addEventListener(TimerEvent.TIMER_COM PLETE, timeEnd);
clockCounter.start();
Is that not how the Timer works? If you have a tip that I'm not aware of, please share! :tini:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.