我遇到了stage.addeventlistner問題。在做了一些研究之後,我發現了一些提示,說明它可能沒有實例化。行stage.addeventlistener給出錯誤;如何實例化階段?
我該怎麼做?
類型錯誤錯誤#1009不能訪問空對象引用的屬性或方法
(線是指是stage.addeventlistener)
僅用重要比特的代碼
package
{
import flash.display.MovieClip;
import flash.events.*;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.geom.Point;
public class TesTrun extends MovieClip
{
var leftPressed:Boolean = false;
var rightPressed:Boolean = false;
var upPressed:Boolean = false;
var downPressed:Boolean = false;
public function TestRun()
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
stage.addEventListener(Event.ENTER_FRAME, loop);
//there is more code down here but i don't think that has to be included
}
}
}
您的標題非常漂亮,但我們已經有一個標記系統和它的索引。 –
好吧,我看到有人這樣做,並認爲這是有幫助的。將停止使用它。 – Jacques
's/its/it's /'(oops) –