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!

Timer

Status
Not open for further replies.

Matteo

Programmer
Mar 7, 2002
43
US
If I wanted to make a timer that was accurate to the second, How should I go about doing this? What should I set the FPS to and how many frames should I make in the program. I would think 1 fps and 60 frames in the program, then at the 60th frame have a counter and when your done you can see how many seconds went by (I don't have flash on this computer atm so I can't start working on it, just trying to get the idea straight.)

~Thanks
~Matteo
 
If your fps is 12fps, than 1 second takes 12 frames. If your fps is 25fps than 1 second takes 25 frames. But you could have a timer running on a looping 1 second movie, whatever the framerate, and it would still be accurate, in theory. Regards,

oldman3.gif
 
over the net frame rates are not constant..depends to a large extent on the viewers technology so a counter using frame rates may end up being quite inaccurate.

getTimer counts in milliseconds from the system clock, is global, and will give a much more accurate reading.
 
Ok getTimer seems good but I have never heard of it. And also this will not be used over the net, it is for home use.
 
Ok, How does the getTimer() fuction work? Now when I am doing the program, I wanted to get a value of the number of clicks on the button divided by the current time elasped since the program started. Can I do this with the getTimer() fuction?
 
daves code is spot on but will return a very small number as getTimer counts in milliseconds.
if you multiply butpress by 60,000 this would give you clicks per minute which might be more meaningful.
 
AHHHH... My code was similar to Daves, but I was getting a very small number and didn't know why. It must of been because it was in milliseconds and I need to multiply it by 60,000. Thanks for info.
 
Ok, I wanted to know if there was anyway better to display my value I get for clicks per Seconds. Right now, if I click 5 times in 10 seconds. It comes up 05. Now I was wondering if there was a way to display this as .5. Any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top