11 Replies Latest reply on Oct 26, 2006 8:16 AM by kglad

    Problem with gotoAndStop

    backpages
      OK, this is driving me crazy. It seems like it should be very easy. I have a simple timeline. I have ActionScript keyframes on frames 1, 5, 10 & 15. I have a random number generator on frame 1. I picks a number between 1 and 3 and then sends the timeline to either frame 5, 10 or 15. Frame 5 is named "news". Frame 10 is named "featured". Frame 15 is named "video". Basically I just want the file to begin at a different point each time, based on the random number generated. I have this ActionScript on frame 1:

      stop();

      var min:Number = 1;
      var max:Number = 3;
      var randNum:Number;
      function randRange():Number {
      randNum = Math.round(Math.random()*(max-min))+min;
      return randNum;
      }
      randRange();

      trace(randNum);

      switch (randNum) {
      case 1:
      trace("one");
      gotoAndStop("news");
      break;
      case 2:
      trace("two");
      gotoAndStop("featured");
      break;
      case 3:
      trace("three");
      gotoAndStop("video");
      break;
      default:
      trace("default");
      }

      I know the random number generator is working properly and I know the switch statement is working properly from the trace information I get. It chooses 1, 2 or 3 and the appropriate part of the switch statement works. However, in all 3 cases the timeline advances to frame 4 and stops. I've never had a problem with any gotoAndStop commands before. Any ideas on why they are not working here? And why does the timeline stop at 4? Thank you very much for any help or insight.