Copy link to clipboard
Copied
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);
}
}
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);
}
}
Copy link to clipboard
Copied
you probably need to remove your listeners if they're no longer relevant after changing frames.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
copy and paste your updated code.
Copy link to clipboard
Copied
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");
}
}
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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);
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now