AS3不会删除EventListener#1009

时间:2015-02-10 00:26:19

标签: actionscript-3

  

错误:TypeError:错误#1009:无法访问a的属性或方法   null对象引用。在ball3gamehelp_fla :: MainTimeline / hitTest()

我正在尝试这样做当你抓到2个球它会带你回到主页但是,当我抓住2个球时,它会加载主页并保持球的数组添加到舞台上,尝试多个删除事件监听器的方法

如果它到达某个像素但是该工作要么

,也试图移除球

如果有人能帮助我,我会非常感激

2 个答案:

答案 0 :(得分:0)

  1. 尝试从舞台上移除球时从阵列中移除球。

    function hitTest(evt:Event) :void
    {
        var length:int = bgame.length - 1;
    
        for ( var j:int = length; j >= 0 ; j--) 
        {
             if (bgame[j].hitTestPoint(Bmitt.x, Bmitt.y, true)) 
             {
                  trace("true");
                  removeChild(bgame[j]);
                  bgame.splice(j, 1);//remove from array
                  Score++;
                  Scoreinstance.text = String(Score);
             }
    
         }
    

    }

  2. 退出功能中的清除间隔

    clearInterval(interval);
    

答案 1 :(得分:0)

您应该使用 removeEventListener 。 例如 removeEventListener(SomeEvent, SomeHandlerName)

相关问题