actionscript-3 - TypeError : Error #2007: Parameter hitTestObject must be non-null. What is this?

标签 actionscript-3 flash error-handling

您好,我正在尝试以两行的形式制作两个Collison墙,并为其指定了实例名称“colission1”和“colission2”,我已使用以下代码使汽车消失,并且当游戏结束时会 pop 游戏结束消息开车来了

addEventListener(Event.ENTER_FRAME, hit1);
function hit1(e:Event):void {

    if (car_mc.hitTestObject(colission2_mc)) 
    {
        gotoAndPlay(2);
        gotoAndStop(2);
        car_mc.visible = false;
        stop();
    }
    else
    {
        car_mc.visible = true;
    }
}

addEventListener(Event.ENTER_FRAME, hit2);
function hit2(e:Event):void {
    if (car_mc.hitTestObject(colission1_mc)) 
    {
        gotoAndPlay(2);
        gotoAndStop(2);
        car_mc.visible = false;
        stop();
    }
    else
    {
        car_mc.visible = true;
    }
}

然后我得到这个错误;
TypeError: Error #2007: Parameter hitTestObject must be non-null.
at flash.display::DisplayObject/_hitTest()
at flash.display::DisplayObject/hitTestObject()
at Gamev1_fla::MainTimeline/hit1()
TypeError: Error #2007: Parameter hitTestObject must be non-null.
at flash.display::DisplayObject/_hitTest()
at flash.display::DisplayObject/hitTestObject()
at Gamev1_fla::MainTimeline/hit2()

最佳答案

您将转到另一个不再存在car_mc或colission2_mc的框架,但是由于您没有删除enterframe侦听器,因此它继续运行hit1并出现错误。删除enterframe侦听器。

关于actionscript-3 - TypeError : Error #2007: Parameter hitTestObject must be non-null. What is this?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30888421/

相关文章:

error-handling - Spring集成中的错误处理

apache-flex - Adobe AIR - 读取 AIR 包外同一文件夹中的文件

apache-flex - 使用 Flex;如何获取服务器时间并不断增加而无需每秒调用

node.js - 如何为生产关闭 Node.js Express(ejs 模板引擎)错误?

css - Vimeo 切入父级的圆 Angular

flash - 将 RTMP 协议(protocol)重定向到另一个 RTMP 流

PHP 将一个用户的数据转移到另一个页面

actionscript-3 - TypeError : Error #1006: value is not a function - What am I doing wrong?

actionscript-3 - AS3 : Can we skip an optional parameter and assign value to the parameter after the skipped one?

flash - YouTube iframe 嵌入的 wmode 参数