2013-08-01 25 views
0

TypeError: Error #1009: Cannot access a property or method of a null object reference. at RECOVER_fyp1_fla::MainTimeline/abc1()TypeError:錯誤#1009:無法訪問空對象引用的屬性或方法。在RECOVER_fyp1_fla :: MainTimeline/abc1()

嗨,這是什麼意思?任何人都可以弄明白嗎?謝謝。

代碼:

swatter.addEventListener(Event.ENTER_FRAME,abc1); 

Mouse.hide(); 



function abc1(e:Event) 
{ 
    swatter.x = mouseX; 
    swatter.y = mouseY; 

    enter code here 

    mosq1.y = mosq1.y + 2; 
    mosq2.y = mosq2.y + 3; 
    mosq3.y = mosq3.y + 4; 
    mosq4.y = mosq4.y + 5; 
    mosq5.y = mosq5.y + 6; 



    if (mosq1.y > 640) 
    { 
     mosq1.y = -50; 
    } 

    if (mosq2.y > 640) 
    { 
     mosq2.y = -50; 
    } 

    if (mosq3.y > 640) 
    { 
     mosq3.y = -50; 
    } 

    if (mosq4.y > 640) 
    { 
     mosq4.y = -50; 
    } 

    if (mosq5.y > 640) 
    { 
     mosq5.y = -50; 
    } 


    if(swatter.hitTestObject(mosq1)) 
    { 
     //SoundMixer.stopAll(); 
     //three_start_sound1.play(); 
     mosq1.parent.removeChild(mosq1); 
    } 

    if(swatter.hitTestObject(mosq2)) 
    { 
     //SoundMixer.stopAll(); 
     //three_start_sound1.play(); 
     mosq2.parent.removeChild(mosq2); 
    } 

    if(swatter.hitTestObject(mosq3)) 
    { 
     //SoundMixer.stopAll(); 
     //three_start_sound1.play(); 
     mosq3.parent.removeChild(mosq3); 
    } 

    if(swatter.hitTestObject(mosq4)) 
    { 
     //SoundMixer.stopAll(); 
     //three_start_sound1.play(); 
     mosq4.parent.removeChild(mosq4); 
    } 

    if(swatter.hitTestObject(mosq5)) 
    { 
     //SoundMixer.stopAll(); 
     //three_start_sound1.play(); 
     mosq5.parent.removeChild(mosq5); 
    } 
} 

enter code here 
+0

圍棋的屬性與您的Flash IDE中的「發佈設置」,然後切換「允許調試」。您也可以使用control-shift-enter在調試模式下進行編譯,它將直接跳轉到有問題的代碼行,並向您顯示調用堆棧以及所有變量的當前狀態。也就是說,你有兩個'在這裏輸入代碼'的條目,至少應該被註釋掉。另外,你正在處理mosq1-5的'y'屬性,但是你在某個時候刪除了這個對象,這意味着併發點擊會拋出上面提到的錯誤。 – Atriace

回答

0

但這些變量:

mosq1.y = mosq1.y + 2; 
mosq2.y = mosq2.y + 3; 
mosq3.y = mosq3.y + 4; 
mosq4.y = mosq4.y + 5; 
mosq5.y = mosq5.y + 6; 

被實例化? Peraphs這些是空的。

錯誤代碼是明確的,你想用一個空對象

相關問題