Copy link to clipboard
Copied
Hello, I'm relatively new to Action Script 3, so I'm having some trouble with an Input Text code.
I have an Input box called "caja" and I want people to enter the right answer, so I have some code in place that supposedly redirects you to another scene depending on your answer. The thing is when I enter the right answer it takes me to the wrong answer scene. The wrong answer does work but for some reason, the other one doesn't. Any ideas?
Code:
var check:Boolean = false;
var input1:String;
var answer = "no";
button_12.addEventListener(MouseEvent.CLICK, checkClick);
function checkClick(event:MouseEvent):void{
input1 = caja.text;
check = true;
if (input1 == answer) {
gotoAndPlay(1, "Scene 4");
}
else gotoAndPlay(110, "Scene 4");
};
Copy link to clipboard
Copied
Hi.
I think your code works.
Probably the Scene 4 only has 110 frames, so when you write to go to Scene 4 and play it, you never get to see the frame 110 because the playback sends you back immediately to the frame 1 from the first scene.
Replace gotoAndPlay with gotoAndStop and you'll probably get the result you want.
I hope it helps.
Regards,
JC
Copy link to clipboard
Copied
No, that can't be it because frame 110 is where the "wrong answer" scene is. The right answer scene is on frame 1 of that same scene.
Thanks anyways
Copy link to clipboard
Copied
I think you mean label when you say scene.
If you want the timeline to go to a specific frame/label you write:
gotoAndStop(1);
//or
gotoAndStop("label");
If you want to go to another scene, you have to write:
gotoAndStop(1, "Scene");
//or
gotoAndStop("label", "Scene");
Of course this all is valid for the gotoAndPlay function as well.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now