2 Replies Latest reply on Nov 21, 2006 6:05 PM by Nephine

    Conditions

    Nephine
      I hope someone could help me with this. It seems simple enough, but I'm probably not writing the script properly. I have two timelines:

      1. In the first timeline ("actions") there are two keyframes.
      The first keyframe:
      quote:

      stop();
      x=0

      This keyframe just declares the value of x.

      The second keyframe:
      quote:

      stop();
      if (x=1) {
      gotoAndPlay("Poem1",1);
      }
      else if (x=2) {
      gotoAndPlay("Poem2",1);
      }

      This keyframe is responsible for checking the value of "x" to see which scene it should go to next.

      2. In the second timeline ("buttons") there is one keyframes, with two buttons.
      The keyframe:
      quote:

      Poem1.onRelease = function() {
      x=1;
      this.gotoAndPlay(3);
      }

      Poem2.onRelease = function() {
      x=2
      this.gotoAndPlay(3);
      }

      Basically these buttons are responsible for changing the value of x. And once a buttons is chosen, the movie skips to the third frame where it runs it's course until the final frame. The final frame checks the value of x to determine which scene to go to.

      Could anyone explain what is wrong with this code? I use Flash MX 2004 version.
        • 1. Re: Conditions
          Level 7
          there is a problem with your IF statements... you are performing an
          assignment on variable "x" and not a comparison as you intended...

          yours
          ------
          if (x=1) {
          > gotoAndPlay("Poem1",1);
          > }
          > else if (x=2) {
          > gotoAndPlay("Poem2",1);
          > }

          should be
          ---------
          if ( x == 1 ) {
          > gotoAndPlay("Poem1",1);
          > }
          > else if ( x == 2 ) {
          > gotoAndPlay("Poem2",1);
          > }

          Nephine wrote:
          > I hope someone could help me with this. It seems simple enough, but I'm
          > probably not writing the script properly. I have two timelines:
          >
          > 1. In the first timeline ("actions") there are two keyframes.
          > The first keyframe:
          >
          quote:

          stop();
          > x=0

          > This keyframe just declares the value of x.
          >
          > The second keyframe:
          >
          quote:

          stop();
          > if (x=1) {
          > gotoAndPlay("Poem1",1);
          > }
          > else if (x=2) {
          > gotoAndPlay("Poem2",1);
          > }

          > This keyframe is responsible for checking the value of "x" to see which scene
          > it should go to next.
          >
          > 2. In the second timeline ("buttons") there is one keyframes, with two buttons.
          > The keyframe:
          >
          quote:

          Poem1.onRelease = function() {
          > x=1;
          > this.gotoAndPlay(3);
          > }
          >
          > Poem2.onRelease = function() {
          > x=2
          > this.gotoAndPlay(3);
          > }

          > Basically these buttons are responsible for changing the value of x. And once
          > a buttons is chosen, the movie skips to the third frame where it runs it's
          > course until the final frame. The final frame checks the value of x to
          > determine which scene to go to.
          >
          > Could anyone explain what is wrong with this code? I use Flash MX 2004
          > version.
          >
          • 2. Re: Conditions
            Nephine Level 1
            Thank you very much. That did the trick. I never knew there was a difference between using 1 and 2 "=" signs.