Copy link to clipboard
Copied
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);
}
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...
...Copy link to clipboard
Copied
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);
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now