December 8, 2010

Javascript: Prototype.js - keep a timer running and maintain scope

If you create a Class with the Prototype.js class system, and you want to keep a timer running (for animation or other purposes), use this function to maintain the proper "this" scope:
runTimer: function() {
    // execute your own code here

    // keep timer running
    setTimeout(function(t) { 
    }, 1000/30, this);

No comments:

Post a Comment