类型错误:错误#1009:无法访问空对象引用的属性或方法 - Event.ENTER_FRAME [英] TypeError: Error #1009: Cannot access a property or method of a null object reference - Event.ENTER_FRAME
本文介绍了类型错误:错误#1009:无法访问空对象引用的属性或方法 - Event.ENTER_FRAME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道回答这个问题的存在的吨的,但搜索一段时间后。我无法找到一个。我知道它与我的 Event.ENTER_SCENE
。
I am aware there are tons of answers to this problem, but after searching for a while. I could not find one. I know it has to do with my Event.ENTER_SCENE
.
下面是我的code:
stage.addEventListener(TouchEvent.TOUCH_BEGIN, touchBegin);
stage.addEventListener(TouchEvent.TOUCH_MOVE, touchMove);
stage.addEventListener(TouchEvent.TOUCH_END, touchEnd);
function touchBegin(e:TouchEvent){
if(oCharUse == true){
if(Math.abs(e.stageX - oChar.x) < 100 && Math.abs(e.stageY - oChar.y) < 100){
oMove = true;
} } }
function touchMove(e:TouchEvent){
if(oCharUse == true){
if(oMove == true){
oChar.x = e.stageX;
oChar.y = e.stageY - 100;
} } }
function touchEnd(e:TouchEvent){
if(oCharUse == true){
oMove = false;
} }
stage.addEventListener(Event.ENTER_FRAME, loop)
function loop (e:Event){
if(_collisionTest.complex(x2x, oChar)){
trace("collision")
}
}
我被告知要添加更多的信息:错误指的是这一行:如果(_collisionTest.complex(x2x2,oChar))
。 _collisionTest,是collisiondetectionkit我下了互联网。它只有两次出现在code你在上面看到。没有任何其他框架。
I was told to add more info: The error refers to this line: if(_collisionTest.complex(x2x2, oChar))
. _collisionTest, is a collisiondetectionkit I got off the internet. And it only appears twice in the code you see above. Not on any other frame.
推荐答案
您需要初始化变量。
var _collisionTest:CollisionTest = new CollisionTest();
这篇关于类型错误:错误#1009:无法访问空对象引用的属性或方法 - Event.ENTER_FRAME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文