Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple timers?

Status
Not open for further replies.

Sajtz

IS-IT--Management
Apr 23, 2002
75
EU
Hi.

As I´m a decent flash-programmer g r a p h i c a l, i´m having problems with the coding-part.

I´m using this peace of code to start at timer.


_root.pausebutton._visible = 0;
//
function restartTimer() {
hours = "00";
minutes = "00";
seconds = "00";
milli = "00";
buttonPressTime = getTimer()/1000-pauseLength;
pause();
}
//
function pause() {
pauseTime = getTimer()/1000;
timing = false;
}
//
function unpause() {
unpauseTime = getTimer()/1000;
pauseLength = (unpauseTime-pauseTime)+pauseLength;
timing = true;
}
//
_root.onEnterFrame = function() {
totalTime = getTimer()/1000-pauseLength;
goTime = totalTime-buttonPressTime;
//
if (timing) {
hours = Math.floor(goTime/3600);
minutes = Math.floor((goTime/3600-hours)*60);
seconds = Math.floor(((goTime/3600-hours)*60-minutes)*60);
milli = Math.floor((gotime-(seconds+(minutes*60)+(hours*3600)))*100);
if (seconds<10) {
seconds = &quot;0&quot;+seconds;
}
if (minutes<10) {
minutes = &quot;0&quot;+minutes;
}
if (hours<10) {
hours = &quot;0&quot;+hours;
}
if (milli<10) {
milli = &quot;0&quot;+milli;
}
}
};
unpausebutton.onRelease=function() {
unpause();
pausebutton._visible = 1;
unpausebutton._visible = 0;
}
pausebutton.onRelease=function() {
pause();
unpausebutton._visible = 1;
pausebutton._visible = 0;
}
reset.onRelease= function() {
restartTimer();
pausebutton._visible = 0;
unpausebutton._visible = 1;
}


Now I´m having 2 problems since I want the timer to work on a multiple sets of frames. If i have the above piece of code on 2 frames, the 2 timers will follow eachothers. So the first question is:
How do I seperate the 2 timers from eachother?

The second problem is that when I move from frame 1 to frame 2, and then back to frame 1 (with a timer), I want the [red]STOP[/red] button to show if the timer is ticking, but now the START button shows evert time I enter the frame.


Thnxs.

/Petter
 
Ok. 2 seconds after I post this thread I came up with a solotion to the &quot;Stop&quot;-button question.

Still problems with the multiple times question though :/
 
Noone who knows how to have multiple timers? Pleeeease :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top