我得到這個真的很煩錯誤 「類型錯誤:錯誤#1009:在monke2_fla無法訪問空對象引用的屬性或方法 :: MainTimeline/UPDATE2()」 我找不到NULL var,除了#1009錯誤之外,任何幫助都會很棒,因爲腳本工作正常。類型錯誤:錯誤#1009無法找到空對象
var randomX:Number = Math.random() * 800;
Banana_mc1.x = randomX;
Banana_mc1.y = 0;
var speed:Number = 10;
var speed2:Number = 5;
var speed3:Number = 2;
var speed4:Number = 6;
Banana_mc1.addEventListener(Event.ENTER_FRAME, moveDown);
var playerScore:int = 0;
var stopLoop = 0;
if (stopLoop == 1) { } else {
function moveDown(e:Event):void
{
Banana_mc1.y += speed;
Banana_mc2.y += speed2;
Banana_mc3.y += speed3;
Banana_mc4.y += speed3;
Banana_mc5.y += speed;
Banana_mc6.y += speed4;
Snake_mc1.y += speed2;
Bunch.y += speed3;
Snake_mc2.y += speed3;
}
}
// KEYS
stage.addEventListener (KeyboardEvent.KEY_DOWN, myFunction) ;
//Monkey.addEventListener(Event.ENTER_FRAME, update);
function myFunction (event: KeyboardEvent)
{
if(event.keyCode == Keyboard.LEFT)
Monkey.x -= 10;
if(event.keyCode == Keyboard.RIGHT)
Monkey.x += 10;
}
var hitAry:Array = [Banana_mc1,Banana_mc2,Banana_mc3,Banana_mc4,Banana_mc5,Banana_mc6];
var hitAry2:Array = [Snake_mc1,Snake_mc2];
stage.addEventListener(Event.ENTER_FRAME, update2);
function update2(e:Event):void
{
var hitAry:Array = [Banana_mc1,Banana_mc2,Banana_mc3,Banana_mc4,Banana_mc5,Banana_mc6];
var hitAry2:Array = [Snake_mc1,Snake_mc2];
for (var i:int=0; i < hitAry.length; i++) {
if (Monkey.hitTestObject(hitAry[i])) {
trace("HIT");
hitAry[i].parent.removeChild(hitAry[i]);
trace(hitAry[i]);
playerScore+=1;
playerScoreText.text = ("" + playerScore);
} else {
trace("MISS"); }
if (Floor.hitTestObject(hitAry[i])) {
trace("HIT The Floor");
hitAry[i].gotoAndPlay(35);
stopLoop = 1;
} else {
trace("MISS"); }
}
for (var b:int=0; b < hitAry2.length; b++) {
if (Monkey.hitTestObject(hitAry2[b])) {
Monkey.Head.gotoAndPlay(23);
trace("HIT");
hitAry2[b].parent.removeChild(hitAry2[b]);
playerScore-=1;
if (playerScore <= 0) { playerScore = 0; }
playerScoreText.text = ("" + playerScore);
} else {
trace("MISS"); }
}
if (Monkey.hitTestObject(allleft)) {
Monkey.Head.gotoAndPlay(23);
trace("BITE");
playerScore-=100;
if (playerScore <= 0) { playerScore = 0; }
playerScoreText.text = ("" + playerScore);
} else {
trace("NO BITE"); }
if (Monkey.hitTestObject(allright)) {
Monkey.Head.gotoAndPlay(23);
trace("BITE");
playerScore-=100;
if (playerScore <= 0) { playerScore = 0; }
playerScoreText.text = ("" + playerScore);
} else {
trace("NO BITE"); }
if (Monkey.hitTestObject(Bunch)) {
trace("HIT BUNCH");
Bunch.parent.removeChild(Bunch);
playerScore+=10;
playerScoreText.text = ("" + playerScore);
}
}
這是一個任務就是在到期我打磚牆,在此先感謝
- 切爾西
這還不夠遠。不幸的是,這是時間軸編碼的缺陷。這可能是因爲您的任何數量的影片剪輯/顯示對象或兒童未正確設置。確保你的實例名稱是正確的。檢查你的父/子層次結構,確保像「Bunch.parent」這樣的東西實際上有一個父對象。添加跟蹤語句以確定在拋出錯誤之前運行的最後一件事情。 –