错误#2025:ActionScript编程问题



问题是每次我试图进入下一个场景backStory它不会带走孩子。我想这样做,当柜台转到4它会把它拿出来,放在一个新的场景中。有办法解决这个问题吗?我不明白如何切换场景

我正在创建一个游戏,我得到这个错误:

ArgumentError:错误#2025:提供的DisplayObject必须是调用者的子级。at flash。display::DisplayObjectContainer/removeChild()在Runner/onEnterFrame()

       package  {
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.events.KeyboardEvent;
        import flash.ui.Keyboard;
        import flash.display.MovieClip;
        import flash.text.TextField;
        import flash.text.TextFormat;
        public class Runner extends MovieClip {
            public var startPage:StartPage = new StartPage();
            public var backStory1:BackStory1 = new BackStory1();
            public var water:Water = new Water();

            public function Runner() {
                addChild(startPage);
                stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
            }
            function onEnterFrame(event:Event):void{
                if(startPage.endStartPage == true){
                    removeChild(startPage);
                    addChild(backStory1);
                    startPage.endStartPage == false;
                }
                if(backStory1.backStory1End == true){ //in backstory1 the bool backstory1end is suppose to be true but it doesnt get to that point
                    removeChild(backStory1);
                    addChild(water);
                    startPage.endStartPage == false;
                }


                }
            }
        }

后台级

    package  {
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.events.KeyboardEvent;
        import flash.ui.Keyboard;
        import flash.display.MovieClip;
        import flash.text.TextField;
        import flash.text.TextFormat;
        public class BackStory1 extends MovieClip {
            var backStory1End:Boolean = false;
            var count:int = 0;
            public function BackStory1() {
                backStory1Text.text = "sssherro";
                if (stage)
                {
                    init(null);

                }
                else
                {
                    addEventListener(Event.ADDED_TO_STAGE,init);
                }
                function init(e:Event):void
                {
                    removeEventListener(Event.ADDED_TO_STAGE, init);
                       nextButton.addEventListener(MouseEvent.MOUSE_DOWN,onButtonClick);
            }
            function onButtonClick(event:MouseEvent):void{
                count++;

                if(count == 1){
                    backStory1Text.text = "awesome1";
                    //backStory1End= true;
                }
                else if(count == 2){
                    backStory1Text.text = "awesome2";
                }
                else if(count == 3){
                    backStory1Text.text = "awesome3 leave game press";
                }
                else if(count == 4){
                    //backStory1Text.text = (String)(counter);
                    backStory1End = true;
        }
    }
    }
        }
    }

下面的行是错误的。

startPage.endStartPage == false;

修复:

startPage.endStartPage = false;