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 6911773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:59:59+00:00 2026-05-27T08:59:59+00:00

Background: Trying to make a ball appear in the same location the mouse is

  • 0

Background: Trying to make a ball appear in the same location the mouse is positioned. Using Box2D Library. Working on a class file (.as)

Issue: The mouse event does not work (I click but nothing happens) . No output errors whatsoever. 🙁

Mouse Event EDIT: Marty Wallace corrected my code, but still the mouse event won’t work.

   private function _clicked(e:MouseEvent)
            {
                sim.addCircle({x:mouseX, y:mouseY, radius:0.25, density:5});
                sim.start();  

Full Code:

package  {

    import flash.display.MovieClip;
    import com.actionsnippet.qbox.*;  
    import flash.events.MouseEvent;

    [SWF(width = 350, height = 600, frameRate = 60)]  

    public class MouseTest extends MovieClip {

        public var sim:QuickBox2D;

        /**
         * Constructor
         */
        public function MouseTest()
        {
            sim = new QuickBox2D(this);  
            sim.createStageWalls();

            addEventListener(MouseEvent.CLICK, _clicked);
        }

        /**
         * ..
         * @param e MouseEvent.CLICK
         */
        private function _clicked(e:MouseEvent)
        {
            sim.addCircle({x:mouseX, y:mouseY, radius:0.25, density:5});
            sim.start();  

        }
    }

}
  • 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-27T09:00:00+00:00Added an answer on May 27, 2026 at 9:00 am

    EDIT by Gabriel Meono:

    QuickBOX2D uses meters instead of pixels. To work with pixels with this library, one must divide each number by 30. I simply added a "/3" to the mouseX / mouseY and it worked!
    I updated your code, thanks!

    Either do this (recommended):

    public var sim:QuickBox2D;
    
    /**
     * Constructor
     */
    public function MouseTest()
    {
        sim = new QuickBox2D(this);  
        sim.createStageWalls();
    
        addEventListener(MouseEvent.CLICK, _clicked);
    }
    
    /**
     * ..
     * @param e MouseEvent.CLICK
     */
    private function _clicked(e:MouseEvent)
    {
        sim.addCircle({x:(mouseX/30), y:(mouseY/30), density:5});
        sim.start();  
    }
    

    Or this (not so recommended, but closer to your code):

    /**
     * Constructor
     */
    public function MouseTest()
    {
        var sim:QuickBox2D = new QuickBox2D(this);  
        sim.createStageWalls();
    
        addEventListener(
            MouseEvent.CLICK,
            function(e:MouseEvent):void
            {
                sim.addCircle({x:(mouseX/30), y:(mouseY/30), radius:0.25, density:5});
                sim.start();
            }
        );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using TCPDF in CakePHP and trying to make some background (grey) for few
I am trying to make a radio button control with a transparent background using
I'm trying use make a div's background transparent using a mixture of CSS3 rgba()
I am trying to make a website with a video background using HTML5's video
Background: Trying to make a simple drop the ball game. The code is located
I'm trying to make a webpage change the background color every one second using
I'm trying to make a div's background color change on mouse over . the
I'm trying to make all rows have a hover background except the header row.
Background I'm trying to make a menu, you hover over the button and the
Im trying to make a game for the iPhone that has background music. So

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.