Skip to main content

clearInterval not working 88 Responses

Last post: 3 months ago | Thread started: Aug 21, 08, 8:47 a.m.

RespondNew TopicDisable Images

  • CyBrain

    Help please. (AS2)
    What on earth could possibly be preventing this interval from being cleared:

    randomWait = function() {
    clearInterval(rwId);
    gotoAndPlay("steam");
    }
    delaySteam = function() {
    rwId = setInterval(randomWait, randomDelay);
    }

    Aug 21, 08, 8:47 a.m. – Permalink
  • CyBrain

    forgot to post the first line:
    var randomDelay:Number = (Math.random() * 1.0 + 0.5) * 1000;

    next note >add note

    You must be logged in to add a note. Login now or register for an account.

    Cancel
    Dog-earAug 21, 08, 8:49 a.m. – Permalink
  • bulletfactory

    could it be that it's working and the time is just too short for frame-based animations?

    put some trace("something happening now"); actions in to see where it's hanging up.

    next note >add note

    You must be logged in to add a note. Login now or register for an account.

    Cancel
    Dog-earAug 21, 08, 8:51 a.m. – Permalink
  • CyBrain

    I had a trace inside the randomWait function that kept repeating roughly every 1 second. That's how I know the interval isn't clearing. Since the numbers being generated are all at least 500 milliseconds, it's not a frame rate issue.

    next note >add note

    You must be logged in to add a note. Login now or register for an account.

    Cancel
    Dog-earAug 21, 08, 8:55 a.m. – Permalink
  • PonyBoy

    i'm thinking it has everything to do w/your interval being a random number...

    • not totally sure what though... but that's got to be root of it.. everything else is correct.PonyBoy
    + add note

    You must be logged in to add a note. Login now or register for an account.

    Cancel
    Dog-earAug 21, 08, 8:58 a.m. – Permalink
  • CyBrain

    The value randomDelay only gets set once, just to delay the framehead that long. Then the interval should get cleared after the goto statement.

    next note >add note

    You must be logged in to add a note. Login now or register for an account.

    Cancel
    Dog-earAug 21, 08, 8:59 a.m. – Permalink
  • pylon

    Is your SWF getting called into another SWF? We've had massive problems with setInterval in that scenario...

    ... or maybe it's to do with the random number, as PB suggests?

    next note >add note

    You must be logged in to add a note. Login now or register for an account.

    Cancel
    Dog-earAug 21, 08, 9:04 a.m. – Permalink
  • CyBrain

    It will be called into another movie eventually, but I'm testing it on its own right now. Unfortunately, I gave up and faked some randomness on the timeline. I'm content with my potato steam and I'm moving on. Thanks for all the help everyone.

    next note >add note

    You must be logged in to add a note. Login now or register for an account.

    Cancel
    Dog-earAug 21, 08, 9:13 a.m. – Permalink
  • PonyBoy

    just for giggles... did you try making the interval global?...

    _global.myInterval = setInterval...

    clearInterval(_global.myInterval…

    next note >add note

    You must be logged in to add a note. Login now or register for an account.

    Cancel
    Dog-earAug 21, 08, 10:27 a.m. – Permalink

Login or Register to respond to this

Skip to main content