Matching Words

Does anyone know how to do something like when a key is pressed, if its Ascii code match a dynamic random text( only one character for the moment), it will go to another character. In other words, it will regonized the character i type match the character of the dynamic random text.

Something like the effect of a game called “House of Dead-Typing of the Dead” Hope i didn’t spell wrongly the name of the game!
Thanx!

You can get the ascii of the last key pressed like so:

Key.getAscii;

From there you can compare the letter (in the form of a number value) with a position in an array, containing your letters.

When i compare the text with the key i press, i get the Ascii code i pressed but get ‘undefined’ for the text(use trace to check)which i wanna compare. Which means im unable to compare them. It seem it couldn’t read the Ascii code from the random dynamic text. Any idea?

well to give you a start, the ascii for the letter ‘a’ is 97 and ‘A’, 65. Based on that, you’re gonna have to deal with an offset for the positions of the elements in the array. for example, if ‘a’ was pressed, in order to access the first element in the array, you’ll have to

asc = Key.getAscii; // you can try changing this to Key.getAscii(); if it doesn't work
elem0 = yourArray[asc-97];

Mind you, this code would only work if the letters pressed were lowercase. And notice I said letters. Other characters will require a bit more code. But play with this first until you get it working and i’ll complete the code including other characters, uppercase, lowercase, numbers, etc.