Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with Algorithm's Timer Class

    Algorithm came up with an awesome Timer Class for Object-Oriented timeouts. He posted it here:
    The Timer class, for object-oriented timeouts

    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!).
    Attached Files Attached Files

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, without looking, let me say this. You must pass in the reference to the timeout
    Code:
    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?
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! Works like a charm!

    I'm still getting this error in Gecko:

    Code:
    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.

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •