SolveErrors
Flash / ActionScript

[AS3] keyboard event wont work :(

6 views

I decided to pick up a copy of O'reilly Actionscript 3 Cookbook today, and I have been going through. One of the first examples it has for keyboard events is:

Code:
package {
    import flash.display.Sprite;
    import flash.events.KeyboardEvent;
    
    public class ExampleApplication extends Sprite {
        public function ExampleApplication(  ) {
            stage.focus = this;
            addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
        }
        
        private function onKeyDown(event:KeyboardEvent):void {
            trace("key down: " + event.charCode);
        }
    }
}
But for some reason it will not work. According to the book stage.focus = this; is all you need for keyboard events to work, am i doing something wrong?

More Flash / ActionScript fixes

Flash8 [RESOLVED] anyone know how to stop a movie speeding up on replay?item customizingAS3 problem onReleaseOutsidePhysically resizing an image using AS3triyng to get eventdispatcher trigger listener in multiple instanceslibrary stuff