The web site for Flash ActionScript 3.0 game developers

 
         
   

CharCode

I am just starting to go through the Flash Game University Book and am having trouble at page 57. When I insert the code that is in the book the dynamic text field displays Characters being pressed, Not Numbers or Codes?

Anyone else have this problem?

Let me know.

This is the code that I am using:

var keyboardText:TextField = new TextField();
addChild(keyboardText);

stage.addEventListener(KeyboardEvent.KEY_DOWN, keydownFunction);
function keydownFunction(event:KeyboardEvent)
{
keyboardText.text = "KeyPressed: "+String.fromCharCode(event.charCode);
}



Copyright Gary Rosenzweig