2013-08-29 69 views
0

我有一個小問題。我在遊戲開始之前創建了一個菜單,帶有「開始」,「加載」和「退出」按鈕。它在一個名爲IntroScreen.as的新類中。點擊一個按鈕時刪除一個孩子

所以,引擎類(Engine.as)就在電影后調用Introscreen:

從這裏
private function ouvertureMenu(e:MouseEvent):void{ 
removeChild(opening); 
introScreen.visible = true; 
options.changeMusic(「」); 

完美。

當我點擊「加載」按鈕時,它會調用另一個名爲SaveRestore.as的類,其中有用於保存和恢復的所有功能。 因此,窗口保存/恢復打開。

但是當我恢復遊戲時,saverestore窗口關閉,但不是Introscreen! (我聽說(音樂背景)我的遊戲在後臺加載)。

所以我想讓我的IntroScreen在我點擊「恢復」時不可見。

我不明白爲什麼它不起作用。我已經把「removeChild之(introScreen)在這樣的SaveRestore.as:

… 
// Restore game data 
if(allSaveData){ 
puzzle.restorePuzzles(allSaveData.puzzleStatus); 
inv.restoreInv(allSaveData.currentInv, allSaveData.allInv); 
options.restoreOptions(allSaveData.optset); 

Engine.newBack = allSaveData.playerLoc.room; 
addEventListener(「repose」, reposePlayer); 
stageRef.dispatchEvent(new Event(「changeBackground」)); 
showConfirm(「restored」, slotNum); 
removeChild(introScreen); 
dispatchEvent(new Event(「closeThis」)); 
} else { 
trace (「No save data found」); 
Engine.restoring = false; 
} 

你知道可能是什麼問題呢?爲什麼introscreen仍清晰可見(該removeChild之不工作) (我使用的是ALPACA open source code

回答

0

它看起來像introScreen的主人是引擎,那就是,你將需要從調用removeChild之。也許這樣解決它?

//in Engine.as: 
    public function removeIntro():void 
    { //logic here, including removeChild(...) 
    } 

    //in SaveRestore.as 
    engineRef.removeIntro(); 
+0

你是什麼意思engineRef?因爲它會導致錯誤1120 .. – user2421975

+0

和Engine.removeIntro();正在使錯誤1061 ..(靜態類) – user2421975

+0

我的解決方案假設某種封裝是在應用程序中強制執行。這可能不適用。 – mfa