27 Feb 10
Be first!
JavaScript Timer Class
Here is a little JavaScript Class which allows you to have timed function calls. Of course there could be different instances of these timers. Here is a example how to use it:
var timer = new Timer( {'interval':1000} ); timer.start( timedFunction ); function timedFunction(){ // called every 1000 milliseconds }
The function timedFunction will be called every 1000 milliseconds. The millisecond interval will be configured within the configuration object, which is given as parameter into the the class constructor. There is also an optional second parameter for the start function to set the scope. This allows you to use the timer within other JavaScript objects. To stop the timer use the stop function.