Using FlashDevelop, I've got a bit of code to detect keyboard events. The problem is, if I run this code from the main class (Main.as) it'll trigger the event, but not if I go to another class.
For instance, I have the main class, and it has this function
addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown);
public function onKeyDown(e:KeyboardEvent):void
{
trace(e.keyCode);
if (gameState == 1){main.onKeyDown(e);}
}
Now, this works fine in the first class. But when I send it to my second class, MainMenu.as, nothing happens.
main = new MainMenu();
addChild(main);
gameState = 1;
There's no message from either class. If I put the event in the second class, nothing happens. All the other events besides keyboard events still work.