Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7016405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:46:49+00:00 2026-05-27T22:46:49+00:00

I am trying to remove a box that i have created on the screen.I

  • 0

I am trying to remove a box that i have created on the screen.I have a box exported as
Box and a ship exported as player, they are both movie clips. this is the code:

package {
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.MouseEvent;

    public class Main extends MovieClip {

        //playermovevar
        private var _player:MovieClip;
        private var _playerSpeed:Number=5;
        private var _destinationX:int;
        private var _destinationY:int;



        //boxaddvar
        private var boxAmount:Number=0;
        private var boxLimit:Number=20;
        private var _root:Object;

        public function Main() {
            createPlayer();

            //playermovlisten
            stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
            stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandlerdown);

            //boxaddlisten
            addEventListener(Event.ENTER_FRAME, eFrame);

            _box.addEventListener(MouseEvent.CLICK, boxclick);


        }

        //playermoving
        private function createPlayer():void {
            _destinationX=stage.stageWidth/2;
            _destinationY=stage.stageHeight/2;

            _player = new Player();
            _player.x=stage.stageWidth/2;
            _player.y=stage.stageHeight/2;
            stage.addChild(_player);
        }


        private function enterFrameHandler(event:Event):void {
            _player.x += (_destinationX - _player.x) / _playerSpeed;
            _player.y += (_destinationY - _player.y) / _playerSpeed;
        }


        private function mouseHandlerdown(event:MouseEvent):void {
            _destinationX=event.stageX;
            _destinationY=event.stageY;
            addEventListener(MouseEvent.MOUSE_UP, mouseHandlerup);

            rotatePlayer();
        }
        private function mouseHandlerup(event:MouseEvent):void {

        }

        private function rotatePlayer():void {
            var radians:Number=Math.atan2(_destinationY-_player.y,_destinationX-_player.x);
            var degrees:Number = radians / (Math.PI / 180) + 90;
            _player.rotation=degrees;
        }
        //boxadding
        private function eFrame(event:Event):void {
            if (boxAmount<=boxLimit) {
                boxAmount++;

                var _box:Box=new Box  ;

                _box.y=Math.random()*stage.stageHeight;

                _box.x=Math.random()*stage.stageWidth;

                addChild(_box);


            } else if (boxAmount >= boxLimit) {
                removeEventListener(Event.ENTER_FRAME, eFrame);
            } else {
                addEventListener(Event.ENTER_FRAME, eFrame);
            }
        }
        function boxclick(event:MouseEvent):void {
            removeChild(_box);
        }
    }

It gives me this error:

1120: Access of undefined property _box. _box.addEventListener(MouseEvent.CLICK, boxclick);

1120: Access of undefined property _box. removeChild(_box);

anyone know whats wrong?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:46:50+00:00Added an answer on May 27, 2026 at 10:46 pm

    Not sure what results you’re wanting but try this and feel free to ask any questions.

    package {
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.MouseEvent;
    
        public class Main extends MovieClip {
    
            //playermovevar
            private var _player:Player;
            private var _playerSpeed:Number=5;
            private var _destinationX:int;
            private var _destinationY:int;
    
    
    
            //boxaddvar
            private var boxAmount:Number=0;
            private var boxLimit:Number=20;
            private var _root:Object;
    
            private var _box:Box;
            private var arrayOfBoxes:Array = new Array(boxLimit);
    
            public function Main() {
                createPlayer();
    
                //playermovlisten
                stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler, false, 0, true);
                stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandlerdown, false, 0, true);
    
                //boxaddlisten
                addEventListener(Event.ENTER_FRAME, eFrame, false, 0, true);
    
    
    
    
            }
    
            //playermoving
            private function createPlayer():void {
                _destinationX=stage.stageWidth/2;
                _destinationY=stage.stageHeight/2;
    
                _player = new Player();
                _player.x=stage.stageWidth/2;
                _player.y=stage.stageHeight/2;
                stage.addChild(_player);
            }
    
    
            private function enterFrameHandler(event:Event):void {
                _player.x += (_destinationX - _player.x) / _playerSpeed;
                _player.y += (_destinationY - _player.y) / _playerSpeed;
            }
    
    
            private function mouseHandlerdown(event:MouseEvent):void {
                _destinationX=event.stageX;
                _destinationY=event.stageY;
                addEventListener(MouseEvent.MOUSE_UP, mouseHandlerup, false, 0, true);
    
                rotatePlayer();
            }
            private function mouseHandlerup(event:MouseEvent):void {
    
            }
    
            private function rotatePlayer():void {
                var radians:Number=Math.atan2(_destinationY-_player.y,_destinationX-_player.x);
                var degrees:Number = radians / (Math.PI / 180) + 90;
                _player.rotation=degrees;
            }
            //boxadding
            private function eFrame(event:Event):void {
                if (boxAmount<=boxLimit) {
                    boxAmount++;
    
                    _box =new Box();
    
                    _box.y=Math.random()*stage.stageHeight;
    
                    _box.x=Math.random()*stage.stageWidth;
    
                    _box.addEventListener(MouseEvent.CLICK, boxclick, false, 0, true);
    
                    arrayOfBoxes.push(_box);
    
                    addChild(_box);
    
    
                } else if (boxAmount >= boxLimit) {
                    removeEventListener(Event.ENTER_FRAME, eFrame);
                } else {
                    addEventListener(Event.ENTER_FRAME, eFrame, false, 0, true);
                }
            }
            function boxclick(evt:MouseEvent):void {
                removeChild(evt.currentTarget as Box);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to remove an Alert box on an external site with Grease
I'm trying to figure out how to remove options from a select box when
I have been trying to create a regular expressions pattern that matches any reference
I am trying to do something similar to the alert box that we get
I am trying to have append and show methods if a check box is
I'm trying to add the jVal attribute to a textbox that I created in
I trying to have a div with child divs that form 2 or more
I have a simple ajax form and I'm trying to validate that it has
I am trying to have a custom infowindow box in the google maps api.
I have a page I created with jQuery, and in this page is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.