2015-02-10 107 views
1

Error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at ball3gamehelp_fla::MainTimeline/hitTest()AS3不會刪除事件偵聽#1009

我目前正試圖使它所以當你發現了2個球,它把你回主頁,但,當我趕上2個球,它加載了主頁,並保持添加到舞臺球的陣列,試過多種方法來移除事件偵聽

也試過removeball如果達到一定的像素,但該研究所的工作要麼

我真的很感激,如果有人可以幫助我

回答

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); 
    
0

您應該使用removeEventListener。 例如 removeEventListener(SomeEvent, SomeHandlerName)