0 Replies Latest reply: Jul 7, 2006 8:31 AM by Nickels55 RSS

    Random Interval before action

    Nickels55 Community Member
      Simple problem, I need a certain amount of time to pass before the movie does something else.
      Right now I have two frames where an animation is taking place. I need anywhere between 3-8 seconds to pass before the animation switches, but I want the time to be random.

      Here is the code in theory...

      x = math.random(3-6 seconds);
      wait x seconds;
      _level0.animation.gotoAndPlay("event");

      I am thinking this might work since the two frames are looping:
      //set the variables on frame 1
      var x = math.Random(112)+32;
      //+32 so that there is at least 2 seconds before anything happens
      y = 1;

      //loop this frame.
      if (y>=x){
      _level0.animation.gotoAndPlay("event");
      }else{
      y++
      }

      There has to be a better way of doing what I want.

      Thanks for any help.