0
我在flash as3中有以下代碼,但是當我編譯爲swf並單擊從gameover屏幕返回到選項頁面的按鈕之一時,錯誤如下所示:錯誤2207:參數子非空
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(GAMEOVER屏幕)的代碼是:
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;
上分辨率的任何援助不勝感激。
關於您的問題,代碼會嘗試刪除位於不同幀或其他幀中的影片剪輯實例,例如,代碼在幀7中會嘗試查找在幀2中動態生成的影片剪輯。我想知道這是否是範圍問題。 – user1087834
當您移動到另一個框架時,閃光燈會自動移除不再出現在新框架中的兒童(如果您返回,則再次重新創建它們)。如果沒有偵聽器或其他對被刪除對象的引用,它最終會收集垃圾。 – jpop
謝謝@jpop所以這意味着我必須使用類來訪問並在同一幀本地執行操作? – user1087834