PDA

View Full Version : setInterval question


hayored
12-09-2002, 10:56 PM
Hi,
I am learning Flash MX and tried to use setInterval function to display current time:

On the first frame I put the code:

function showTime() {
delete objTime ;
objTime = new Date();
ws_time = objTime.getHours() + ":" + objTime.getMinutes() + ":" + objTime.getSeconds() ;
myTime.text = ws_time ;
}
setInterval(showTime(), 1000);

On the second frame I put a dummy command, so I could put breakpoint
a = a + 1;

On the third (the last) frame I put:
gotoAndPlay(2);

Without debug Flash crushes, but with debbuger I see it creates
level0.instance2,
level0.instance4
and so on, until it crushes.
When I try to see property of this level0.instance... Flash crushes too.

Any explanation what happens?

Thanks,

Yh

Billy T
12-10-2002, 04:17 AM
I think the crashes are due to something else in your file

the set interval should look like this

setInterval(showTime, 1000);

cheers

Billy T
12-10-2002, 04:39 AM
anyone know why flash clocks are always an hour fast on the mac?

farafiro
12-10-2002, 09:54 AM
Originally posted by Billy T
anyone know why flash clocks are always an hour fast on the mac? heheheeeeeeee, it's not flash man
check the clock for the system and see if the Automaticl adjust clock for daylight

farafiro
12-10-2002, 10:04 AM
hayored
I donno what u r trying to do with the dummy code but if u deleted the braces from the function in the setIntervale, all will work fine, even in one framefunction showTime() {
delete objTime ; //u don't need this too
objTime = new Date();
ws_time = objTime.getHours() + ":" + objTime.getMinutes() + ":" + objTime.getSeconds() ;
myTime.text = ws_time ;
}
setInterval(showTime, 1000);

Billy T
12-10-2002, 12:58 PM
Originally posted by farafiro
if u deleted the braces from the function in the setIntervale, all will work fine,

yep that's what I said

what does daylight savings have to do with it? Flash gets the time from the system clock and displays it. Problem is when my comp clock says its 1:15 the flash clock will say its 2:15...

cheers

farafiro
12-10-2002, 01:00 PM
no, there is a diff.
try it first and tell me, when u check it u don't change the system clock, u just change what u see

Billy T
12-10-2002, 01:17 PM
I stand corrected :rolleyes:

You can't turn off daylight savings in os x but when I changed my timezone to chicago or something then flash displayed the correct time...

I will never doubt you again :p

farafiro
12-10-2002, 01:23 PM
:o :rolleyes: