오류 # 1009 : null 개체 참조의 속성이나 메서드에 액세스 할 수 없습니다. MethodInfo-10()의 이 코드를 실행하는 동안이 오류가 발생합니다. 누구든지 내가 뭘 잘못하고 있는지 말해 줄 수 있어요. 오류가있는 곳이나 오류의 행을 표시하지 않습니다. 감사합니다동작 스크립트 3.0 오류
package
{
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
public class Main extends MovieClip
{
public function Main()
{
stop();
start_btn.addEventListener(MouseEvent.CLICK, gothere);
function gothere(clickInfo:MouseEvent)
{
start_btn.removeEventListener(MouseEvent.CLICK, gothere);
nextFrame();
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, key_pressed);
function key_pressed(event:KeyboardEvent):void
{
switch (event.keyCode)
{
case Keyboard.UP :
{
player.y += -5;
if ((wall1.hitTestPoint(player.x - player.width/2, player.y - player.height/2,true)) || (wall2.hitTestPoint(player.x - player.width/2, player.y - player.height/2,true)))
{
player.y += 5;
nextFrame();
playagain_btn.addEventListener(MouseEvent.CLICK, goback);
function goback(event:MouseEvent):void
{
playagain_btn.removeEventListener(MouseEvent.CLICK, goback);
prevFrame();
}
}
else if ((wall1.hitTestPoint(player.x + player.width/2, player.y - player.height/2,true)) || (wall2.hitTestPoint(player.x + player.width/2, player.y - player.height/2,true)))
{
player.y += 5;
nextFrame();
playagain_btn.addEventListener(MouseEvent.CLICK, goback1);
function goback1(event:MouseEvent):void
{
playagain_btn.removeEventListener(MouseEvent.CLICK, goback1);
prevFrame();
}
}
else if (player.hitTestObject(finish))
{
gotoAndStop(4);
}
break;
};
case Keyboard.DOWN :
{
player.y += 5;
if ((wall1.hitTestPoint(player.x - player.width/2, player.y + player.height/2,true)) || (wall2.hitTestPoint(player.x - player.width/2, player.y + player.height/2,true)))
{
player.y += -5;
nextFrame();
playagain_btn.addEventListener(MouseEvent.CLICK, goback2);
function goback2(event:MouseEvent):void
{
playagain_btn.removeEventListener(MouseEvent.CLICK, goback2);
prevFrame();
}
}
else if ((wall1.hitTestPoint(player.x + player.width/2, player.y + player.height/2,true)) || (wall2.hitTestPoint(player.x + player.width/2, player.y + player.height/2,true)))
{
player.y += -5;
nextFrame();
playagain_btn.addEventListener(MouseEvent.CLICK, goback3);
function goback3(event:MouseEvent):void
{
playagain_btn.removeEventListener(MouseEvent.CLICK, goback3);
prevFrame();
}
}
else if (player.hitTestObject(finish))
{
gotoAndStop(4);
}
break;
};
case Keyboard.LEFT :
{
player.x += -5;
if ((wall1.hitTestPoint(player.x - player.width/2, player.y - player.height/2,true)) || (wall2.hitTestPoint(player.x - player.width/2, player.y - player.height/2,true)))
{
player.x += 5;
nextFrame();
playagain_btn.addEventListener(MouseEvent.CLICK, goback4);
function goback4(event:MouseEvent):void
{
playagain_btn.removeEventListener(MouseEvent.CLICK, goback4);
prevFrame();
}
}
else if ((wall1.hitTestPoint(player.x - player.width/2, player.y + player.height/2,true)) || (wall2.hitTestPoint(player.x - player.width/2, player.y + player.height/2,true)))
{
player.x += 5;
nextFrame();
playagain_btn.addEventListener(MouseEvent.CLICK, goback5);
function goback5(event:MouseEvent):void
{
playagain_btn.removeEventListener(MouseEvent.CLICK, goback5);
prevFrame();
}
}
else if (player.hitTestObject(finish))
{
gotoAndStop(4);
}
break;
};
case Keyboard.RIGHT :
{
player.x += 5;
if ((wall1.hitTestPoint(player.x + player.width/2, player.y - player.height/2,true)) || (wall2.hitTestPoint(player.x + player.width/2, player.y - player.height/2,true)))
{
player.x += -5;
nextFrame();
playagain_btn.addEventListener(MouseEvent.CLICK, goback6);
function goback6(event:MouseEvent):void
{
playagain_btn.removeEventListener(MouseEvent.CLICK, goback6);
prevFrame();
}
}
else if ((wall1.hitTestPoint(player.x + player.width/2, player.y + player.height/2,true)) || (wall2.hitTestPoint(player.x + player.width/2, player.y + player.height/2,true)))
{
player.x += -5;
nextFrame();
playagain_btn.addEventListener(MouseEvent.CLICK, goback7);
function goback7(event:MouseEvent):void
{
playagain_btn.removeEventListener(MouseEvent.CLICK, goback7);
prevFrame();
}
}
else if (player.hitTestObject(finish))
{
gotoAndStop(4);
}
break;
}
}
}
}
}
};
코드에 MethodInfo-10() 함수가 없습니다. 오류는 널 (비공개, 초기화되지 않음) 객체 참조의 필드에 액세스하려고한다는 것을 의미합니다. 파일> 제작 설정> 디버깅 허용을 클릭하여 오류가 발생한 정확한 행을 확인합니다. – Organis
오류 # 1009 : null 개체 참조의 속성이나 메서드에 액세스 할 수 없습니다. Function/Main/$ constructor/key_pressed()에서 \t입니다. 설정 변경 후 나타나는 오류입니다. – Fahad
중첩 된 기능을 대괄호로 묶을 때 가장 많이 발생하는 오류입니다. @Organis에서 제시하는대로 Main()과 동일한 수준으로 이동하고 프로젝트의 모든 곳에 유지하십시오. 이렇게하면 반드시 디버깅 및 확장 기능이 향상됩니다. – Vesper