;

PDA

Click to See Complete Forum and Search --> : clock problem


imladris
08-24-2005, 08:45 AM
i have placed the following code in frame 1 which then displays the current time in relevant dynamic text box.
Any ideas what i have missed because the time doesn't update itself-it just stays at the time you entered the page at

now=new Date()
//txt1.text=now.getHours()+":"+now.getMinutes()+":"+now.getSeconds()
h=now.getHours()
if (h<10){
h="0"+h
}
m=now.getMinutes()
if (m<10){
m="0"+m;
}
s=now.getSeconds()
if (s<10){
s="0"+s
}
ms=now.getMilliseconds()
if (ms<10){
ms="0"+ms
}

txt1.text=h+":"+m

pherbrick
08-24-2005, 04:52 PM
Hmm. The compiler let you get away with not using semicolons?

Anyway, you need a loop using onEnterFrame() or some other means of repeatedly executing the code. A low frame rate is okay (I used 12) since you're only looking a minutes or seconds, and reduces cpu processing load. I was going to post a solution zip file, but I can't open the manage attachments window - oops, now its working. Enjoy :).

Peter

P.S. Alternatively, you can add a second key frame and create a "gotoAndPlay(1);" loop.

imladris
08-25-2005, 10:15 AM
i cant open your attachment - says it was created using a later version of km.
cant put version5 on for the moment cause i have a few probs with my pc

thanks

pherbrick
08-25-2005, 12:50 PM
4.7.2 version attached; I kept my old executable :).

Anybody posting for help, please mention if you're not using the latest release version of KoolMoves. The trial version is not always the latest release version, so if you're using the trial version please make a note of the version number under the Help Menu > About KoolMoves.