2 Replies Latest reply on Jan 25, 2014 7:46 AM by tayfun808

    Simple IF statement with ActionScript 2.0

    tayfun808

      Hi and please do not judge my poor scripting and just tell me what I'm doing wrong, I'll handle the rest. Thanks.

      Basicly, I want to show certain pages depending on the x variable. But this code always ends up in gotoAndStop("2") even if the x variable is greater than -5, so the code doesn't work.

      Here's my code:

      if (x <= -5) {

           gotoAndStop("2");

        } else if ((x > -5) && (x < 0)) {

           gotoAndStop("3");

        } else if (x == 0) {

           gotoAndStop("4"); 

        } else if ((x > 0) && (x < 5)) {

           gotoAndStop("5");

        } else if (x >= 5) {

           gotoAndStop("6");

      }

        • 1. Re: Simple IF statement with ActionScript 2.0
          kglad Adobe Community Professional & MVP

          i don't see anything wrong with your code, but you're probably not executing when you should and/or x is not what you think it is.

           

          to debug, use the trace function.  if you don't understand how to correct your problem after using the following, copy and paste the trace output.

           

           

          trace(x+" "+(typeof(x)));

          if (x <= -5) {

               gotoAndStop("2");

            } else if ((x > -5) && (x < 0)) {

               gotoAndStop("3");

            } else if (x == 0) {

               gotoAndStop("4"); 

            } else if ((x > 0) && (x < 5)) {

               gotoAndStop("5");

            } else if (x >= 5) {

               gotoAndStop("6");

          }

          • 2. Re: Simple IF statement with ActionScript 2.0
            tayfun808 Level 1

            My mistake... They should be gotoAndStop(2), not gotoAndStop("2")... I'm such a fool