3 Replies Latest reply on Aug 3, 2010 6:40 AM by kglad

    How to use set interval to fire event every 5 seconds when if statement is met?

    prodigalmaster Level 2

      Here is an extract of code from something im making:


      if (MC_battleTrigR1a.hitTest(this._x, this._y, true)) {
           if (random(220) == 0) {
           //random(220) the code is onEnterFrame and so this random function is called repeatedly until eventually random(220) == 0;
           //every 5 seconds->  trace("5sec"); and gotoAndStop("battle");


      The player walks into an area, within a random amount of time or after 5 seconds it should send the player to the frame labelled: battle

      It works with the random(220) but I dont know how to make it definetly go to frame: battle after 5 seconds.

      I dont know how to use setInterval correctly, I have tried and failed.
      The code is nested in onEnterFrame
      fps:  24

      frame label: treePath

      frame number: 17