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

TextInput: error when checking text

Contributor ,
Aug 03, 2016 Aug 03, 2016

I have seven frames with TextInput fields and I'm getting random errors. you type the text, and when you hit enter, it checks the input and goes to the next frame if correct. Sometimes a certain frame will work and other times it will jump back a few frames. Sometimes it will just erase the text that was typed. My file was working fine yesterday and now frame 10 is messed up (again). Debug tells me a certain line of code is bad even tho it worked before. Sometimes debug will actually fix certain errors. Copying code from a different frame will fix it sometimes. Sometimes changing the text it looks for will fix it. Is Flash just unstable with textinputs? I tried other coding and it still fails on same frame.

stage.focus = ping_10;

stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown10);

function myKeyDown10(e: KeyboardEvent): void {

if (e.keyCode == Keyboard.ENTER && ping_10.text == "asdf") {

  gotoAndStop(11);

}

}

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

Contributor , Aug 03, 2016 Aug 03, 2016

Fixed it by capturing the charCode instead of the keystroke:

ping_11.addEventListener(KeyboardEvent.KEY_DOWN,handler);

function handler(event:KeyboardEvent){

   if(event.charCode == 13 && ping_11.text == "129.210.1.0"){

       gotoAndStop(12);

   }

}

Translate
Community Expert ,
Aug 03, 2016 Aug 03, 2016

you probably need to remove your listeners if they're no longer relevant after changing frames.

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
Contributor ,
Aug 03, 2016 Aug 03, 2016

now frame 10 works and 12 is bad. I tried this:

removeEventListener(KeyboardEvent.KEY_DOWN, myKeyDown11);

From the frame before. Also tried removing all of the listeners. Still not working. This is the last of the seven textinputs.

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 ,
Aug 03, 2016 Aug 03, 2016

copy and paste your updated code.

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
Contributor ,
Aug 03, 2016 Aug 03, 2016

I removed two of the input frames. Changing it to Keyboard.SPACE works. This is crazy.  Debug continually says the  if (e.keyCode line is bad on any frame the error occurs. Frame 10 failed one of the last times I tested, then worked afterwards.

removeEventListener(KeyboardEvent.KEY_DOWN, myKeyDown4);
removeEventListener(KeyboardEvent.KEY_DOWN, myKeyDown5);
removeEventListener(KeyboardEvent.KEY_DOWN, myKeyDown7);
removeEventListener(KeyboardEvent.KEY_DOWN, myKeyDown10);
removeEventListener(KeyboardEvent.KEY_DOWN, myKeyDown11);

stage.focus = ping_12;

stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown12);
function myKeyDown12(e: KeyboardEvent): void {
if (e.keyCode == Keyboard.ENTER && ping_12.text == "12") {
  gotoAndStop(13);
  trace ("12");
}
}

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
Contributor ,
Aug 03, 2016 Aug 03, 2016

I reduced the inputs to two, and got it to work. Now when I run the swf file from the folder it will fail half of the time. Must be a bug...

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
Contributor ,
Aug 03, 2016 Aug 03, 2016
LATEST

Fixed it by capturing the charCode instead of the keystroke:

ping_11.addEventListener(KeyboardEvent.KEY_DOWN,handler);

function handler(event:KeyboardEvent){

   if(event.charCode == 13 && ping_11.text == "129.210.1.0"){

       gotoAndStop(12);

   }

}

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