I have 2 classes, the one is the main, and the other let's say Tank class, so where I need to define this events:
addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
private function onKeyDown(e:KeyboardEvent):void{
trace(e.keyCode);
}
private function onKeyUp():void{
trace(e.keyCode);
}
I don't know why but when I define this function and add the listeners in the Tank class, and then create the Tank object in the Main class the addChild(tank), that event doesn't work, can you give me an advice on where is better and neccesary to put those events?