[問題] AS3.0 Keyboard 的靜態屬性未定義
我在研究 AS3 模擬鍵盤事件的程式
目前是作成按下滑鼠左鍵的時候去觸發按下鍵盤的事件
但是卡在一個小地方
Keyboard.A 應該是等於 65
但是編譯錯誤,他說是未定義
以下附上原始檔
http://140.118.9.222/etrex/as3/keyboardSimulate/keyboardSimulate.html
http://140.118.9.222/etrex/as3/keyboardSimulate/keyboardSimulate.fla
以下附上程式碼
//事件監聽
function reportKeyDown(event:KeyboardEvent):void
{
var str:String = "Key Pressed: " + String.fromCharCode(event.charCode) +
" (character code: " + event.charCode + ")";
T.text = str;
trace(str);
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);
//事件模擬
function simulateKeyDown(keyCode:uint):void
{
var e:KeyboardEvent = new KeyboardEvent( KeyboardEvent.KEY_DOWN, true,
false, keyCode, 0 );
stage.dispatchEvent( e );
}
//滑鼠事件
function reportMouseDown(event:MouseEvent):void
{
//var keyCode:uint = Keyboard.A;
//simulateKeyDown(keyCode);
simulateKeyDown(65);
}
stage.addEventListener(MouseEvent.MOUSE_DOWN, reportMouseDown);
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.118.9.202
※ 編輯: etrexetrex 來自: 140.118.9.202 (02/05 12:40)
※ 編輯: etrexetrex 來自: 140.118.9.202 (02/05 12:47)
※ 編輯: etrexetrex 來自: 140.118.9.202 (02/05 12:47)
※ 編輯: etrexetrex 來自: 140.118.9.202 (02/05 12:47)
→
02/05 12:48, , 1F
02/05 12:48, 1F
推
02/05 12:59, , 2F
02/05 12:59, 2F
→
02/05 13:01, , 3F
02/05 13:01, 3F
推
02/05 13:03, , 4F
02/05 13:03, 4F
推
02/05 22:53, , 5F
02/05 22:53, 5F
→
02/05 22:54, , 6F
02/05 22:54, 6F