View Full Version : Problem with Algorithm's Timer Class

07-08-2003, 01:42 AM
Algorithm came up with an awesome Timer Class for Object-Oriented timeouts. He posted it here:

For the most part, it works great! However, I'm having problems with the clearTimeout() function.

I'm working on an OO Message Ticker script, that uses the Timer Class. The only real problem is that I have to invoke obj.clearTimeout(0) several times before it takes effect. Really, I'm not entirely sure what the parameter should be. Not passing anything seems to void the functionality of it.

There also seems to be an error that pops up in Mozilla, but doesn't seem to stall the script at all.

If anyone could take a look at my script and the bundled timer class, I'd appreciate it. I know that Beetle is familiar with it, as well as Algorithm (of course!). :D ;) :thumbsup:

07-08-2003, 02:30 AM
Well, without looking, let me say this. You must pass in the reference to the timeout

function SomeConstructor()
this.timer = new Timer( this );
this.timeout = this.timer.setTimeout( "someMethod", 1000 );

SomeConstructor.prototype.anotherMethod = function()
this.timer.clearTimeout( this.timeout );
Got that?

07-08-2003, 02:43 AM
Thanks! Works like a charm!

I'm still getting this error in Gecko:

Warning: reference to undefined property Timer.set[i]
Source File: file:///C:/Oxygen/api/timer.js
Line: 107

I know it's in the Timer Class, and not part of my code, but it'd be nice to get this fixed... whatever it is.

07-08-2003, 02:49 AM
I don't know, but I have had bad luck running some complex JS w/o a webserver. I know it sounds weird, but try uploading that or running it on your localhost.

I'll look at the code, too.