0

我在 Flash 的输出窗口中出现错误。它说:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at 
    game.fla::MainTimeline/removeAllClips()[game.fla.MainTimeline::frame1:17]
    game.fla::MainTimeline/playWinterLevel()[game.fla.MainTimeline::frame5:55]

这是我认为是罪魁祸首的一段代码:

var summerOptionImage:SummerOption = new SummerOption();
summerOption.addChild(summerOptionImage);
summerOptionImage.x=35;
summerOptionImage.y=128;
summerOptionImage.buttonMode = true;
summerOptionImage.addEventListener(MouseEvent.CLICK, playSummerLevel);

function playSummerLevel(event:MouseEvent){
    gotoAndStop("playSummerLevel");
    removeAllClips();

    stageHolder3.removeChild(introStage2);


}
function playWinterLevel(event:MouseEvent){
    gotoAndStop("playWinterLevel");
    removeAllClips();
    stageHolder3.removeChild(introStage2);
    stageHolder2.removeChild(backgroundStage);
}

在时间线上

function removeAllClips(){
    while (stageHolder3.numChildren > 0) {
    stageHolder3.removeChildAt(0);
    }
    while (stageHolder2.numChildren > 0) {
    stageHolder2.removeChildAt(0);
    }
}
4

0 回答 0