我对 stage.addeventlistner 有疑问。在做了一些研究之后,我发现了一些提示,它可能没有被实例化。
我怎么做?
typeerror 错误 #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
}
}
}