2012-11-16 63 views
0

我試圖跑,我在Flex Builder 4.6創建的Adobe AIR應用程序。此應用程序出於各種原因需要能夠處理鍵盤事件。如何獲得AIR應用程序的過程鍵盤輸入

我嘗試以下形式:

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:mx="library://ns.adobe.com/flex/mx" 
        keyDown="keyPressed(event)"> 
<fx:Declarations> 
    <!-- Place non-visual elements (e.g., services, value objects) here --> 
</fx:Declarations> 
<fx:Script> 
    <![CDATA[ 
     import mx.controls.Alert; 
     import mx.events.FlexEvent; 

     private var connection:NetConnection; 

     public function keyPressed(event:KeyboardEvent):void 
     { 
      Alert.show("Pressed: "+event.keyCode,"key Event"); 
     } 

    ]]> 
</fx:Script> 
... Other Stuff... 
</s:WindowedApplication> 

這似乎並沒有工作。我點擊結果窗口並按鍵。什麼都沒發生。

我找到在直播窗口中的錯誤,或者是有別的東西,我需要爲了讓我的應用程序正確處理鍵盤輸入呢?

有人請指教...

回答

0

您是否添加了事件偵聽器?

stage.addEventListener(KeyboardEvent.KEY_DOWN,reportKeyDown);

+0

是的,我做到了。在啓動功能中有這樣的呼叫。它根本不起作用。 –

相關問題