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

gotoAndStop not working for dynamic text scoring

Contributor ,
Mar 04, 2016 Mar 04, 2016

gotoAndStop for score not working . when my score is 30 it should go to frame 5

stop();

var score:Number=0;

movieClip_1.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_2);

function fl_MouseOverHandler_2(event:MouseEvent):void

{

  score=score+10;

  text1.text=String(score);

}

if(score==30) {

  gotoAndStop(5);

}

TOPICS
ActionScript
259
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

correct answers 1 Correct answer

LEGEND , Mar 04, 2016 Mar 04, 2016

The code as you show it will only execute once, immediately upon entering that frame - it does not monitor for a change in value.   Unless you are continuously returning to that frame so that the code executes repeatedly, it is only going to execute that if() code once while you are in the frame.  If the score is not 30 when you are entering that frame then it will not go to frame 5.

Move it inside the function where it will execute every time the score changes and see if it does what you want...

...
Translate
LEGEND ,
Mar 04, 2016 Mar 04, 2016
LATEST

The code as you show it will only execute once, immediately upon entering that frame - it does not monitor for a change in value.   Unless you are continuously returning to that frame so that the code executes repeatedly, it is only going to execute that if() code once while you are in the frame.  If the score is not 30 when you are entering that frame then it will not go to frame 5.

Move it inside the function where it will execute every time the score changes and see if it does what you want...

function fl_MouseOverHandler_2(event:MouseEvent):void

{

  score=score+10;

  text1.text=String(score);

  if(score==30) {

     gotoAndStop(5);

  }

}

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