我在 Flash as3 中有以下代码,但是当我编译为 swf 并单击从游戏结束屏幕返回选项页面的按钮之一时,错误出现如下:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/removeChild()
at FourSeasonsOfElements_v47_fla::MainTimeline/removeWinterScene()
at FourSeasonsOfElements_v47_fla::MainTimeline/playAgain()
第 3 帧(游戏结束屏幕)中的代码是:
playagainbutton.addEventListener(MouseEvent.CLICK, playAgain);
function playAgain(event:MouseEvent){
gotoAndStop("options");
removeWinterScene();
removeAutumnScene();
removeSummerScene();
MovieClip(root).gameTime = 0;//reset time
}
从 1 到 7 时间线的长关键帧中的动作:
function removeWinterScene(){
MovieClip(root).removeChild(winterbg);
MovieClip(root).removeChild(shadebg1);
MovieClip(root).removeChild(winterHeading);
}
其他第 7 帧中的冬季游戏场景帧在时间轴中有代码:
stop();
var winterbg:WinterScene = new WinterScene();
var shadebg1:fadeShade = new fadeShade();
var winterHeading:WinterSeasonTitle = new WinterSeasonTitle();
addChildAt(winterbg,0);//move the winter background in the background.
addChildAt(shadebg1,1);
addChildAt(winterHeading,1);
winterHeading.x = 200;
非常感谢有关该决议的任何帮助。