Hi folks, need a bit of help with regards to showing the time in Flash, the movie I'm making looks like a news broadcast and I am going to be displaying the time (hours and minutes) in two separate dynamic text boxes named ch and cm. The problem that I am having is that when, for example the time is 5 past 2, the time displays as 14: 5, rather than 14:05 so the zero is missing, any ideas?
My code is this:
var dt, timeint;
dt = new Date();
ch = dt.getHours();
cm = dt.getMinutes();
cs = dt.getSeconds();
timeint=setInterval(timer,1000);
function timer() {
dt = new Date();
ch = dt.getHours();
cm = dt.getMinutes();
cs = dt.getSeconds();
} Problem displaying duration time Netstream - kirupaForum:: 2 posts - 2 authors - Last post: Jul 31Problem displaying duration time Netstream ActionScript 3.0. http://www.kirupa.com/forum/showthread.php?t=305018HOME |
Thought I would post this in here rather than start a new thread, but would it be possible to pull the time from an online server even if it is running as a screensaver?
You can get the server time by using PHP or some other such server-side language. Just write a PHP script that gets the server time, then use loadVars or some other method to pass that into flash. Not sure what you mean about the screensaver. CRITICAL PROBLEM: display of read/unread marking. Posting Time :: 2 posts - 2 authors - Last post: Oct 22, 2003CRITICAL PROBLEM: display of read/unread marking. Posting Time. by IanC/OZ - 10/ 22/03 3:11 AM. Just in the few messages in Speakeasy since http://forums.cnet.com/5208-7598_102-0.html?forumID=51&threadID=80&messageID=752HOME |
I knocked this up yesterday when I wanted to know the time, but also wanted to waste some time....
It should do exactly what you need, obviously with some changes to suit your project.
http://www.duncanhall.net/duncs_clock.fla
Thanks for all the help guys thats its working :)
can you use a conditional to see if you have single digit number
and simply add "0" to the string?
cm=dt.getMinutes();
if(cm<10){
var nString:String="0"+cm;
cm=nString;
}
are you placing that new code in the timer function? if you place it outside of the function (and therefore outside of the setInterval), the timer function will rewrite the variable and lose the zero every second or whatever your interval is!
Thanks, I'll try that out
The Zero does appear for all of about 2 seconds but then it disappears again leaving the single digit once more?
I'll let you know in about 20 minutes lol :)
I placed the new code inside the timer function, any other ideas what it might be seeing as I've 45 minutes before I can check it out again lol
Where's The Advantage In Windows Genuine Advantage?
Stocks Bounce After S&P Joins Bear Market |