![](/img/trans.png)
[英]AS3 error 1119: Access of undefined property CHANGE through a reference with static type flash.events:MouseEvent
[英]AS3 error 1119 in platformer game: “Access of possibly undefined property KeyCode through a reference with static type flash.events:Event.”
我正在嘗試創建一個簡單的Platformer作為分配的一部分,但是我似乎無法克服這個錯誤。 它告訴我問題出在所有keyCode行的第11列中,但是我引用的教程使用的是完全相同的代碼,沒有問題。
stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeysDown);
function checkKeysDown(event:Event):void{
//making the booleans true based on keycode
if(event.keyCode == 37){
leftKey = true;
}
if(event.keyCode == 39){
rightKey = true;
}
if(event.keyCode == 38){
upKey = true;
}
}
這是該教程的鏈接 。 我究竟做錯了什么?
您正在使用Event
類作為函數checkKeysDown
參數,該函數沒有這樣的屬性。 應該使用KeyboardEvent
類型的參數聲明。
function checkKeysDown(event:KeyboardEvent):void {
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.