1
votes

The problem is that every time I try to go on to the next scene backStory it doesn't remove the child. I want to make it so that when the counter goes to 4 it will take it out and put in a new scene. Is there a way to fix this issue? I don't understand how I can switch scenes

I am creating a game and I get this error :

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display::DisplayObjectContainer/removeChild() at 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;

                }





                }
            }

        }

Backstory class

    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;

        }

    }
    }
        }
    }
1
Can you provide additional information about exactly what you've done here, what you're hoping to accomplish, what you've tried and what you are unclear on? These answers typically don't get much attention because they come with little to no explanation so the problem to solve is unclear.user562566

1 Answers

0
votes

Following line is wrong.

startPage.endStartPage == false;

Fix:

startPage.endStartPage = false;