PDA

View Full Version : Leading zero ?


Manni
11-30-2001, 05:26 PM
How do I get a leading zero on dynamic text fields with 2 digits?
Like 01- 09, 10-99

:confused:

Ricod
12-01-2001, 10:53 AM
what R U trying to do, what did u get and how did u do it ?

Manni
12-01-2001, 12:07 PM
Hi Ricod,

I'm trying to display the running time of an MC.
I have to say that this is my very first try on AS and there will be a better or easier way to do it.
This is what I have so far (framerate set to 25):

onClipEvent (enterFrame) {
sec = Math.floor(_currentframe/25);
min = 0;
if (sec >= 60) {
sec = Math.floor((_currentframe/25)-60);
min += 1;
}
}

The variables return 1 - 9 instead of 01 - 09.
How do I get a readout of 01 - 09 ?

tg
12-01-2001, 07:33 PM
onClipEvent(enterFrame){
//get date and time
now = new Date();

hours = now.getHours();
if (hours > 12) {
hours = hours - 12;
suffix = "PM";
}else{
suffix = "AM";
}
min = now.getMinutes();
//here i check the length of the min var if the length is < 2 i concatenate a 0 to it.
if (min.toString().length<2) min="0"+min;
sec = now.getSeconds();
//here i check the length of the sesc var if the length is < 2 i concatenate a 0 to it.
if (sec.toString().length<2) sec="0"+sec;

year = now.getFullYear();
day = now.getDate();
month = now.getMonth();

time = hours + ":" + min + ":" + sec + " " + suffix;
curDate = (month+1) + "/" + day + "/" + year;

_root.theDate = curDate + newline + time;
}

Manni
12-01-2001, 08:57 PM
thx tg, that helped :)

Jesse
12-02-2001, 08:33 AM
Robert Penner's scientific notaion and decmial converter proto does this too... ahh search the forums for it.