-
[CS3] Timer Not Counting Up
I'm trying to make a timer for a puzzle I made and I can't get it to count at all. I just get "0:0:0". Here's my code:
Code:
function oneUp() {
seconds++;
trace("interval called");
}
setInterval(oneUp,1000);
stop();
var seconds = 0;
var minutes = 0;
var hours = 0;
timeDisplay = hours+":"+minutes+":"+seconds;
if (seconds=60) {
seconds = 0;
minutes++;
}
if (minutes=60) {
minutes = 0;
hours++;
}
if (seconds<10) {
seconds = "0"+seconds;
}
if (minutes<10) {
minutes = "0"+minutes;
}
if (hours<10) {
hours = "0"+hours;
}
I also uploaded an example of what I got. Thanks in advance for any help.
-
Working code, notice all the changes I made to make this property work as a timer, especially the logic of the interval function.
PHP Code:
stop(); var timeInt = setInterval(updateTime,1000); var seconds = 0; var minutes = 0; var hours = 0;
timeDisplay.text = "00:00:00";
function updateTime() { seconds++; if (seconds==60) { seconds = 0; minutes++; } if (minutes==60) { minutes = 0; hours++; } secStr = seconds; minStr = minutes; hourStr = hours; if (seconds<10) secStr = String("0"+seconds); if (minutes<10) minStr = String("0"+minutes); if (hours<10) hourStr = String("0"+hours); timeDisplay.text = hourStr+":"+minStr+":"+secStr; }
-
That doesn't seem to be working. All it does is show "00:00:00" and doesn't go up.
-
I noticed you have the var field filled in your text properties, never put anything in there - remove it and it should work.
-
-
Forgive the double post, but how can I stop the timer from out side of the movie clip in the main time line? I tried:
Code:
pCounter.clearInterval(timeInt);
pCounter.clearInterval(updateTime);
But that didn't work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|