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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:18:53+00:00 2026-05-24T00:18:53+00:00

i am currently creating a shooting game , currently i have a main class

  • 0

i am currently creating a shooting game , currently i have a main class which is the place where i add “main childs” at, and i have a object class “gunner”, i added that “gunner” to my main, and i have a eventListener,MOUSE_CLICK on the gunner class, however when i did a click nothing happens, why is that so? in my case the gunner is supposed to shoot bullets. is the event not being dispatched to my gunner object?

constructor of my main class.

    public function waterMain() 
    {
        Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
        canPlay = true;
        soundTimer = new Timer(300, 1);
        soundTimer.addEventListener(TimerEvent.TIMER, waterSoundHandler, false, 0, true);
        waterMovementSound = new pondSound();
        bg = new Background(stage);
        myRippler = new Rippler(bg , 20, 5, 5);
        //event listeners
        addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
        addEventListener(TouchEvent.TOUCH_MOVE, onTouchBegin);
        addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoveTriggered);

        addChild(bg);
        touchPoints = Multitouch.maxTouchPoints;
        if (Multitouch.supportsGestureEvents && Multitouch.supportsTouchEvents)
        {
            trace("Multitouch gesture supported");
            var inputField:TextField = new TextField();
            inputField.border = true;
            inputField.wordWrap = true;
            inputField.text = "Multitouch gesture,touch supported,MTP : "+touchPoints;
            addChild(inputField);
        }else if (Multitouch.supportsTouchEvents)
        {
            trace("touch  supported");
            var inputField2:TextField = new TextField();
            inputField2.border = true;
            inputField2.wordWrap = true;
            inputField2.text = "Multitouch touch supported,MTP : "+touchPoints;
            addChild(inputField2);
        }
        //game
        //creating gunner
        var gun:gunner = new gunner(stage);
        gun.x = stage.stageWidth / 2;
        gun.y = stage.stageHeight;
        addChild(gun);
    }

gunner class

package  
{
    import flash.display.MovieClip;
    import flash.display.Stage;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Point;
    /**
     * ...
     * @author ...
     */
    public class gunner extends MovieClip
    {
        private var _stageRef:Stage;
        public function gunner(stageRef:Stage) 
        {
            _stageRef = stageRef;
            addEventListener(Event.ENTER_FRAME, rotateTurret);
            addEventListener(MouseEvent.CLICK, fireBullet);
        }


        private function rotateTurret(evt:Event):void 
        {
            //calculations, distance, angle etc
            var a:Number = _stageRef.mouseX - this.x;
            var b:Number = _stageRef.mouseY - this.y;
            var angRad:Number = Math.atan2(b, a);
            var angDeg:Number = (angRad * 180 / Math.PI);

            rotation = angDeg;
        }
        private function fireBullet(mouseEvt:MouseEvent):void
        {

            _stageRef.addChild(new bullet(_stageRef, 500,500));
        }
    }

}

bullet class

public class bullet extends MovieClip
{
    //variables
    private var _bulletSpeedVector:Point;
    private var _stageRef:Stage;
    private var _maxX:Number = 1024;
    private var _maxY:Number = 768;
    public function bullet(stageRef:Stage,x:Number,y:Number) 
    {
        _stageRef = stageRef;
        this.x = x;
        this.y = y;
        addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
    }
    private function loop(e:Event) : void
    {
        //move bullet

        /*if (this.x > _maxX || this.x < 0)
            removeSelf();
            else if (this.y > _maxY || this.y < 0)
            removeSelf();
            */
    }
    private function removeSelf() : void
    {
        removeEventListener(Event.ENTER_FRAME, loop);

        if (_stageRef.contains(this))
            _stageRef.removeChild(this);
    }


}
  • 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-24T00:18:54+00:00Added an answer on May 24, 2026 at 12:18 am

    i am not sure why this happens, but when i changed it to MouseEvent.MOUSE_DOWN, it works. but with click it cant work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently creating an explicit reference to this in the outer class so that
I am currently creating a website and have some javascript that works in all
I'm currently creating a Wordpress theme and I have an area which displays the
I'm currently creating an application for a customer that will allow them to automatically
I am currently creating an e-commerce site using C# ASP.NET MVC and have just
Im currently creating a tile-based game for android. Using java via dalvik JVM. im
I am currently creating a console application which is reading from a folder which
I am currently creating an application that has a user, the user can follow
I am currently creating a web application that will be deployed in an intranet
I'm currently creating a stock management system that uses multiple warehouses (with sub locations)

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.