javascript setInterval on an object's function only calls 2x
<pre><code>var focus = true;

function z() {
    this.t = 0;
    this.p = function (t) {
        if (focus == true) {
            this.t = t;
            alert(this.t);

        }

    }
}
var zp = new z();
setTimeout('zp.p(0)', 100);
window.setInterval('zp.p(1)', 2000);
var ftimer = setTimeout('focus=false', 2000);

document.addEventListener('mousemove', function (e) {
    clearTimeout(ftimer);
    focus = true;
    ftimer = setTimeout('focus=false', 2000);
}, false);
</code></pre>

<p>I have this code. but for some reason it only alerts twice even with continuous mouse movements. I have been working at this and investigating in firebug and focus is true when I am moving my mouse. I have been trying to figure out what is going on.. even if I do this:</p>

<pre><code>function z() {
    this.t = 0;
    this.p = function (t) {
        if (focus == true) {
            this.t = t;

        }
        alert(this.t);

    }
}
</code></pre>

<p>It still only alerts twice. </p>

<p>I have tried using a looping setTimeout function too but that doesnt work either. It is driving me crazy. </p>
