I am trying to make a game that requires the user to input a lot of different keys in a very short amount of time.
If I use something like this:
setInterval(function () {
trace("The ASCII code for the last key typed is: "+Key.getAscii());
},100);
it will display trace many times, but I only want it once for each key press.
If I do this
[COLOR=#993300]var[/COLOR] keyListener:[COLOR=#993300]Object[/COLOR] = [COLOR=#993300]new[/COLOR] [COLOR=#993300]Object[/COLOR]COLOR=#000000[/COLOR];
keyListener.[COLOR=#993300]onKeyDown[/COLOR] = [COLOR=#993300]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"The ASCII code for the last key typed is: "[/COLOR]+[COLOR=#993300]Key[/COLOR].[COLOR=#993300]getAscii[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR];
[COLOR=#993300]Key[/COLOR].[COLOR=#993300]addListener[/COLOR]COLOR=#000000[/COLOR];It’s way too slow, and only some of my key presses get traced.