开发者

Event handling for keyboard strokes

I'm trying to get familiar with the whole keyboard event detection thing.

Here's my sample code.

<fx:Script>
    <![CDATA[

        import flash.events.KeyboardEvent;
        import开发者_Python百科 mx.controls.Alert;

        private function init():void{
            addEventListener(KeyboardEvent.KEY_DOWN,reportKeyDown);   
        }

        private function reportKeyDown(event:KeyboardEvent):void {
            Alert.show("a key was pressed");
        }

    ]]>
</fx:Script>

As you can see, I'm at stage 0 of playing around with it, but it won't work. Anyone has any idea what I should be doing instead?

Thanks


Try this:

stage.addEventListener(KeyboardEvent.KEY_DOWN,reportKeyDown);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜