Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Simple IF statement with ActionScript 2.0

New Here ,
Jan 25, 2014 Jan 25, 2014

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");

}

TOPICS
ActionScript
610
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 25, 2014 Jan 25, 2014

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");

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 25, 2014 Jan 25, 2014
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines