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

Text input action AS3

Contributor ,
Feb 25, 2010 Feb 25, 2010

Copy link to clipboard

Copied

I have a text input field on the timeline that I want the user to enter specific information in. When that information is correctly entered, I need the timeline to progress.

I successfully used the following AS2, but I cant find corresponding code for AS3

on (keyPress "x") {
gotoAndPlay("s05");
}

Any help on converting this function to AS3 is greatly appreciated.

Views

35.5K

Translate

Translate

Report

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 , Feb 25, 2010 Feb 25, 2010

I'm a little surprised you don't get any error message, but I guess your incomplete conditional doesn't break any laws as written (ended prematurely with a semicolon...

  if(pane.text == "x");
     gotoAndPlay("s04");

should be...

  if(pane.text == "x") gotoAndPlay("s04");

Votes

Translate

Translate
LEGEND ,
Feb 25, 2010 Feb 25, 2010

Copy link to clipboard

Copied

You can use an Event.CHANGE listener for the textfield and then test its value in the event handler function to see if it agrees with the required string...

inputtField.addEventListener(Event.CHANGE, testEntry);

function testEntry(evt:Event):void {

     if(inputField.text == "whatever"){

          // do stuff

     }

}

Votes

Translate

Translate

Report

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
Contributor ,
Feb 25, 2010 Feb 25, 2010

Copy link to clipboard

Copied

Thanks, I modified the code to match the text input file name, and added a line for the action I want:

pane.addEventListener(Event.CHANGE, addEntry);

function addEntry(evt:Event):void {
     if(pane.text == "x");
     gotoAndPlay("s04");
}

I do not get anny errors, but nothing happens.

Votes

Translate

Translate

Report

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
LEGEND ,
Feb 25, 2010 Feb 25, 2010

Copy link to clipboard

Copied

I'm a little surprised you don't get any error message, but I guess your incomplete conditional doesn't break any laws as written (ended prematurely with a semicolon...

  if(pane.text == "x");
     gotoAndPlay("s04");

should be...

  if(pane.text == "x") gotoAndPlay("s04");

Votes

Translate

Translate

Report

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
Contributor ,
Feb 25, 2010 Feb 25, 2010

Copy link to clipboard

Copied

Thanks, works perfect!

Votes

Translate

Translate

Report

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
LEGEND ,
Feb 25, 2010 Feb 25, 2010

Copy link to clipboard

Copied

LATEST

You're welcome

Votes

Translate

Translate

Report

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