我的极短小游戏在舞台上有 4 个对象,游戏完成后,我希望将它们全部从舞台上移除并重新启动游戏。
我已经这样设置了(大部分位被取出)
function mainGame():void {
            var theCoin:coin = new coin();
            var cupOne:cup = new cup();
            var cupTwo:cup = new cup();
            var cupThree:cup = new cup();
            stage.addChild(theCoin);
            trace(theCoin.parent);
            stage.addChild(cupOne);
            trace(cupOne.parent);
            stage.addChild(cupTwo);
            trace(cupTwo.parent);
            stage.addChild(cupThree);
            trace(cupThree.parent);
            function prepReset():void 
            {
                cupOne.removeEventListener(MouseEvent.CLICK, liftCup1);
                cupTwo.removeEventListener(MouseEvent.CLICK, liftCup2);
                cupThree.removeEventListener(MouseEvent.CLICK, liftCup3);
                stage.addChild(resetBtn);
                resetBtn.addEventListener(MouseEvent.CLICK, resetGame);
            }
            function resetGame(event:MouseEvent):void 
            {  
                stage.removeChild(cupOne);
                stage.removeChild(cupTwo);
                                    stage.removeChild(cupThree);
                letsgoagain();
            }
        } // end mainGame
        function letsgoagain():void
        {
            stage.removeChild(resetBtn);
            mainGame();
            trace("RESET")
        }
这一切都在第一次正常工作。一旦它第二次重置,我得到
Game Started
[object Stage]
[object Stage]
[object Stage]
[object Stage]
RESET
[object Stage]
[object Stage]
[object Stage]
[object Stage]
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display::DisplayObjectContainer/removeChild()
    at Function/coinGame/$construct/mainGame/resetGame()[*\coinGame.as:147]
Cannot display source code at this location.
父级仍然是舞台,但 stage.removeChild 不是正确的语法?我不明白。Stackoverflow,请您指出正确的方向吗?