Skip to main content
New Participant
August 8, 2013
Question

Crossword puzzle - Delete vs. Backspace

  • August 8, 2013
  • 1 reply
  • 764 views

Hi

I’ve created a crossword puzzle in AS3 where you have to type in the characters individually into their blocks, for e.g. if the answer is true, you will have to type T into block 1, R into block 2, etc.

My code to test the answer is:

if(true1.text.slice(-2,-1)+true2.text.slice(-2,-1)+true3.text.slice(-2,-1)+ true4.text.slice(-2,-1)=="TRUE") {

                                answerTrue=true;

                } else…

If the answer is incorrect and you press the Backspace button to remove the current character and retype the correct character it works perfect and validates as correct.

BUT if you press the Delete button and you then also retype the correct character it validates it as incorrect. (It only validates as incorrect if you press Delete after the character or if you press it twice.)

Why is the Delete button causing it to break and do you have any suggestions on how I can fix this?

  The only other solution I can think of is to just disable the Delete button, but that isn’t as easy as I thought it would be.

Any help will be appreciated.

This topic has been closed for replies.

1 reply

kglad
Community Expert
August 8, 2013

why are you applying the slice method to your textfields and checking the next-to-last character?

e-d_zignAuthor
New Participant
August 8, 2013

Thanks, I've changed it to substr(true1.length-1, true1.length) and it works perfect

kglad
Community Expert
August 8, 2013

you're welcome.