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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:18:55+00:00 2026-05-26T02:18:55+00:00

A previous question has gotten me thinking. Is it possible to simulate a MouseEvent.CLICK

  • 0

A previous question has gotten me thinking. Is it possible to simulate a MouseEvent.CLICK to get fired by just firing first a MOUSE_DOWN followed by a MOUSE_UP.

As per Adobe’s doumentation.
“… For a click event to occur, it must always follow this series of events in the order of occurrence: mouseDown event, then mouseUp. The target object must be identical for both of these events; otherwise the click event does not occur. Any number of other mouse events can occur at any time between the mouseDown or mouseUp events; the click event still occurs.” http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/InteractiveObject.html#event:click

From my tests it shows that the CLICK event is NOT constructed from the ActionScript 3 event queue. Or is something wrong with the code?

See:

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

[SWF(backgroundColor="0xFFFFFF", frameRate="30", width="800", height="600")]

public class Test extends Sprite
{
    private var spr:Sprite = new Sprite();
    public function Test()
    {
        trace("Test()");
        this.addEventListener(Event.ADDED_TO_STAGE,init);
    }
    public function init(e:Event):void
    {
        trace("init()");
        spr.graphics.beginFill(0xFF0000);
        spr.graphics.drawRect(0,0,200,80);
        spr.graphics.endFill();
        addChild(spr);
        addEventListener(Event.ENTER_FRAME, onEnterFrame);
        spr.addEventListener(MouseEvent.CLICK, onClick);
    }
    private var tick:int = 0;
    private function onEnterFrame(e:Event):void
    {
        if (tick == 1) spr.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_DOWN,true,false));
        if (tick == 2) spr.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_UP,true,false));
        if (tick == 3) spr.dispatchEvent(new MouseEvent(MouseEvent.CLICK,true,false));
        tick++;
    }
    private function onClick(e:MouseEvent):void
    {
        trace("onClick() MouseEvent.CLICK dispatched"); 
    }
}
}

I should get TWO ‘onClick()’ events instead of one.

  • 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-26T02:18:56+00:00Added an answer on May 26, 2026 at 2:18 am

    The reason you cannot is that all three types are created by the plugin, and are not dependent upon each other.

    MouseEvent.MOUSE_DOWN is fired as soon as you press on an interactive object.
    MouseEvent.MOUSE_UP is fired as soon as you release the mouse, it does not depend upon the mouse click having started a MOUSE_DOWN within the same InteractiveObject.
    MouseEvent.CLICK will only be fired when both events take place in the same object without the cursor leaving the object between the itnerval of mouse down and mouse up.

    So you can see that there is a simple case, or two even, in which both MOUSE_DOWN and MOUSE_UP are fired, but CLICK is not called because the event is not a CLICK.

    Furthermore, the ability to simply dispatch a MouseEvent.CLICK event makes it unnecesasry to create fake user interaction by firing multiple mouse events, when only one is called for. It would be awkward to have to track each object clicked in the mouse down listener, in order to check that the moue up should also trigger a click. You would also need to remove references when a ROLL_OUT event happened.

    In short, the CLICK event is really a lot more than the MOUSE_DOWN and MOUSE_UP events. It is also managing that the events happened in succession and on the same display object without leaving the object. When that happens, and ONLY when that happens flash dispatches a CLICK event.

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

Sidebar

Related Questions

This question has to do with my previous question where I get errors trying
I realise this question has been asked before however the previous answers have gotten
Note: This question has broadened in scope from previous revisions. I have tried to
From a previous question I have seen that the CLR has workstation and server
This question follows on from a previous question, that has raised a further issue.
This question is directly related to my previous question ASP.NET AJAX Is it possible
This question has been asked many times before but none of the previous ones
Carrying on from my previous question, which has now been solved: Issue with Pointers
I know this question has been asked before, but none of the previous answers
In my previous question, someone has commented that write a .NET Stream to two

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.