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

Input Text

New Here ,
Jun 08, 2018 Jun 08, 2018

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

};

TOPICS
ActionScript
271
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 ,
Jun 08, 2018 Jun 08, 2018

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

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 ,
Jun 08, 2018 Jun 08, 2018

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

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 ,
Jun 08, 2018 Jun 08, 2018
LATEST

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.

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