Skip to main content
Inspiring
August 3, 2016
Answered

TextInput: error when checking text

  • August 3, 2016
  • 1 reply
  • 673 views

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

}

}

This topic has been closed for replies.
Correct answer mhunter

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...


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

   }

}

1 reply

kglad
Community Expert
Community Expert
August 3, 2016

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

mhunterAuthor
Inspiring
August 3, 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.

kglad
Community Expert
Community Expert
August 3, 2016

copy and paste your updated code.