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

  • Home
  • SEARCH
  • 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 7017631
In Process

The Archive Base Latest Questions

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

So I have a box exported as Box in my library. I have tried

  • 0

So I have a box exported as Box in my library. I have tried :

package {

    import flash.display.MovieClip;
    import flash.events.*;

    public class Main extends MovieClip {

        private var _box:Box=new Box  ;
        private var boxAmount:Number=0;
        private var boxLimit:Number=16;


        private var _root:Object;
        public function Main() {

            addEventListener(Event.ENTER_FRAME, eFrame);

            addEventListener(MouseEvent.MOUSE_DOWN, mouseclick);
        }

        private function eFrame(event:Event):void {
            if (boxAmount <= boxLimit) {
                boxAmount++;
                _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);
            }
        }
    }
}

But it did not work as planned.

What I am trying to do is make my box stay on the screen at a random place on the stage and remove it when clicked (but that will come later). This code is for some reason adding the object to the stage and then removing it and adding it again up to 16 times.

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:56:20+00:00Added an answer on May 27, 2026 at 10:56 pm

    I it seems like you have created one _box, and re-add it to the timeline on enter frame. It should work if you create a new box instance inside the eFrame function rather than before it, then you keep reassigning to the same variable name, rather than reusing the one object eg:

    package {
    
    import flash.display.MovieClip;
    import flash.events.*;
    
    public class Main extends MovieClip {
    
    
        private var boxAmount:Number=0;
        private var boxLimit:Number=16;
    
    
        private var _root:Object;
        public function Main() {
    
            addEventListener(Event.ENTER_FRAME, eFrame);
    
            addEventListener(MouseEvent.MOUSE_DOWN, mouseclick);
        }
    
        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);
    
    
    
    
    
            }
        }
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my Box adapter that extends BaseAdapter public class BoxAdapter extends BaseAdapter {
I have a box of selectors all sharing the class. widgetContainer can hold 3
I have this box: <div class=message_box_red id=commentForm_error_name style=width: 409px; height: 0px; border: 0; margin:
I have input box txtRefreshInterval which allow only integer. <td><span class=sfFormlabel>Refresh Interval</span></td> <td><input type=text
I'm trying to learn html and jquery. My issue is that I have box
I have Windows box and I wish to invoke a .sh script on a
I have a box, when I click on it, I want the box animate
I have text box to enter a phone number. I'm using AJAX MaskedEditExtender and
I have a box built via html borders. I want to connect the bottom
I have text box in which your adds values in comma separated values. Once

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.