4 Replies Latest reply on Jun 3, 2008 3:09 PM by clbeech

    simple variable?

    Peter.reteP
      ok.. on frame 1 on my time line I set a variable:

      jumpframe = "100";

      Later in the time line I use the variable: gotoAndPlay(jumpframe);
      when it hits that it goes to and plays from frame 100.. all is good

      then I have a button inside a mc that I want to change the value of that variable to 200. (and another button that would set it to 300):

      on(release){
      root.jumpframe = "200";
      }

      When it hits the same gotoAndPlay(jumpframe); I was hoping it would then go to and play from frame 200 (or 300 depending on which button I clicked)

      Basically, I'm trying to get the buttons to change the value of the variable, and not by increments like +5, but it's just not working.. I've spent a good 2 hours messing with different syntax and still no luck.

      please help

      thoughts?

        • 1. Re: simple variable?
          robdillon Most Valuable Participant
          If you are setting jumpframe to "100" and then calling gotoAndPlay(jumpframe), then you'll need to have a frame label with the name "100". You will never, ever, get to frame 100 by trying to get to frame "100". They are two totally different things.

          If you want to change the value of a variable then you have to reach the variable. If you are using as2 then the base level of the movie would be _root, not root. And, again, you probably want to specify a number not a string:

          on (release) {
          _root.jumpframe = 200;
          }

          This may or may not work for you.
          • 2. Re: simple variable?
            Peter.reteP Level 1
            not quite understanding your first paragraph.

            but i do know if i write

            jumpframe = "100"; // on frame 1

            and

            gotoAndPlay(jumpframe); // on frame 10

            and play the movie, it plays the first 10 frames and then jumps to frame 100 and continues to play.

            but you're saying I can never do this? I'm confused because it is working.

            • 3. Re: simple variable?
              Peter.reteP Level 1
              not quite understanding your first paragraph.

              but i do know if i write

              jumpframe = "100"; // on frame 1

              and

              gotoAndPlay(jumpframe); // on frame 10

              and play the movie, it plays the first 10 frames and then jumps to frame 100 and continues to play.

              but you're saying I can never do this? I'm confused because it is working.

              • 4. Re: simple variable?
                clbeech Level 3
                Flash does 'recognize' numbers within Strings as number representations, in fact one can even perform operation on them - however Rob is right, it's best not to use them as strings in that way and just use the numeric value - including in the gotoAndPlay() method.

                but even so, the call needs to be to: _root.jumpframe = X; <-valueX