Double-click on the propagation of the event

I have a couple of Sprites on my screen and I want to write a single event handler to handle the double click on any one of these Sprites. The following approach works for every type of event except DOUBLE_CLICK:

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

     public class Main extends Sprite
     {
          public function Main()  {

               var circle1:Sprite = new Sprite();
               var circle2:Sprite = new Sprite();
               
               circle1.graphics.lineStyle(1, 0xFF0000);
               circle1.graphics.beginFill(0xFFFFFF);
               circle1.graphics.drawCircle(0, 0, 10);
               circle1.graphics.endFill();
               
               circle2.graphics.lineStyle(1, 0xFF0000);
               circle2.graphics.beginFill(0x000000);
               circle2.graphics.drawCircle(0, 0, 10);
               circle2.graphics.endFill();
               
               circle1.x = 30; circle2.x = 60;
               circle1.y = 30; circle2.y = 30;
               
               this.addChild(circle1);
               this.addChild(circle2);
               
               this.mouseChildren = false;
               this.doubleClickEnabled = true;
               this.addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick);
          }
          
          private function onDoubleClick(e:MouseEvent):void {
               trace("DOUBLE_CLICK event fired");
                        // e.target.scaleX = 2; e.target.scaleY = 2;
          }
     }
}

I don't want to change this:

this.mouseChildren = false;
this.doubleClickEnabled = true;
this.addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick);

to do this:

circle1.mouseChildren = false;
circle1.doubleClickEnabled = true;
circle1.addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick);


circle2.mouseChildren = false;
circle2.doubleClickEnabled = true;
circle2.addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick);

To make it work, because in my application, I get a lot of Sprites. In my opinion, a unique event and the target property are better than hundreds of event listeners. Am wrong me or must add event listeners to each Sprite?

var circle1:Sprite = new Sprite();
var circle2:Sprite = new Sprite();

Circle1.Graphics.LineStyle (1, 0xFF0000);
Circle1.Graphics.beginFill (0xFFFFFF);
Circle1.Graphics.drawCircle (0, 0, 10);
Circle1.Graphics.endFill ();

Circle2.Graphics.LineStyle (1, 0xFF0000);
Circle2.Graphics.beginFill (0x000000);
Circle2.Graphics.drawCircle (0, 0, 10);
Circle2.Graphics.endFill ();

Circle1.x = 30;
Circle2.x = 60;
Circle1.y = 30;
Circle2.y = 30;

this.addChild (circle1);
this.addChild (circle2);

stage.doubleClickEnabled = true;
stage.mouseChildren = true;
for (var i: uint = 0; i
{
Try
{
Sprite (this.getChildAt (i)) .doubleClickEnabled = true;
}
catch (error)
{
}

}

stage.addEventListener (MouseEvent.DOUBLE_CLICK, onDoubleClick);

function onDoubleClick(e:MouseEvent):void
{
Try
{
e.target.scaleX = 2;
e.target.scaleY = 2;
}
catch (error)
{

}
}

Tags: Adobe Animate

Similar Questions

  • Double-click event does not tire/triggered by double clicking on the left side of the tree node

    I have the following tree of Flex

    <mx:Tree id="Tree" left="0" right="0" top="0" bottom="0"
            
    alternatingItemColors="[#EEEEEE, white]" dataProvider="{lsEspecie}"
            
    dragEnabled="true" dragMoveEnabled="true" dropEnabled="true" labelField="item"
            
    labelFunction="tree_labelFunc" showRoot="false"
            
    doubleClickEnabled="true" doubleClick="Tree_DoubleClick(event)">
    </mx:Tree> 

    When I double click on the ICON and to the right of the side on any node, double-click event is triggered as expected. But when clicking on any part of the left side of the node double click is not triggered

    DoubleClickNotFiring.png

    Is there a way to make the double click event fire when happens on the left side of the node?

    The problem has been resolved with this class of FixedTree

    import flash.display.InteractiveObject;
    import flash.events.Event;

    import mx.controls.Tree;
    import mx.core.mx_internal;

    use namespace mx_internal;

    public class FixedTree extends Tree {

    public function FixedTree() {
          super();
       }

    override protected function createChildren():void {
          super.createChildren();

    getListContentHolder().selectionLayer.addEventListener(Event.ADDED, selectionLayerChildAddedHandler);
       }

    private function selectionLayerChildAddedHandler(e:Event):void {
          // ListBase:5790 creates a SpriteAsset for the selectionLayer but does not set mouseEnabled to false

    InteractiveObject(e.target).mouseEnabled = false;
       }

    }

  • DETECT mouse double click in the 3D Pdf 3D content

    I have a 3D Pdf and I want to perform different actions in case of a simple mouse click and double click of the mouse. For simple click, I use the property " " " onMouseUp" and it works fine. Double click the property 'onMouseDoubleClick' doesn't seem to work.

    Could someone run a custom action in the case of a double click?

    Code

    runtime.overrideSelection = true;

    mouseEventHandler var = new MouseEventHandler();

    mouseEventHandler.onMouseUp = true;

    mouseEventHandler.onMouseDoubleClick = true;

    mouseEventHandler.onEvent = myMouseHandlingFunction;

    runtime.addEventHandler (mouseEventHandler);

    The mouse double click event handler does not seem to work.

    However, the following code example is similar through the combination of MouseUp and time

    var timer = false;
    var oneClick = false;
    var myT;
    var myMouseHandler = function( event ) {
      timer = true;
      if (oneClick === true) {
      host.app.alert("double click");
      }
      oneClick = false;
    };
    
    var myTimeHandler = function( event ) {
      if ((event.deltaTime < 0.1) && (timer === true)) {
      timer = false;
      oneClick = true;
      myT = event.time;
      return;
      }
      if ((event.time - myT) >= 0.5) {
      timer = false;
      oneClick = false;
      return;
      }
    };
    
    var mouseEventHandler = new MouseEventHandler();
    mouseEventHandler.onMouseDown = false;
    mouseEventHandler.onMouseUp = true;
    mouseEventHandler.onMouseMove = false;
    mouseEventHandler.onMouseDoubleClick = true;
    mouseEventHandler.onEvent = myMouseHandler;
    
    var timeEventHandler = new TimeEventHandler();
    timeEventHandler.onEvent = myTimeHandler;
    
    runtime.addEventHandler( mouseEventHandler );
    runtime.addEventHandler( timeEventHandler );
    
  • Double-click on the graph in the map does not work

    Hello
    I had created an application where the user can click on the map and a marker will be created and it stores values x y and stored in the database and the user can also drag the marker and place it in the appropriate position and after the user drag and drop the marker we have a "confirm" to send the values of y from x to the database. I need to remove that confirm the button and replace only with double click where user double clicks on the marker settings must pass.

    To drag the marker, I use the mousedown event, but when I add the doubleclick event his does not work

    gr.doubleClickEnabled = true;
    gr.addEventListener (MouseEvent.DOUBLE_CLICK, registerComplaint);
    gr.addEventListener (MouseEvent.MOUSE_DOWN, mousedownGraphic);

    even when I comment on the mouse to the bottom of the double click event on the graphic marker does not work.

    Help me in this task I need to do urgently.

    Concerning
    Arun Mohan

    While I can't possibly guess the cause of your problem, there is an easy solution for this.

    ...
    // record the time for the last mouse down
    private var _lastMouseDownTime:uint = new Date().time;
    // how fast the second mouse down needs to be to qualify for double click
    private var _doubleClickThreshold:uint = 500;
    ...
    // traces mouse down and double click
    private function mouseDown(e:MouseEvent):void {
                trace("mousedown");
                var mouseDownTime:uint = new Date().time;
                if(mouseDownTime - _lastMouseDownTime <= _doubleClickThreshold){
                    trace("doubleclick");
                }
                _lastMouseDownTime = mouseDownTime;
    }
    
  • Update to iOS 10.0.1 iPhone is, double click on the home screen no longer shows apple pay

    Update to iOS 10.0.1 on an iPhone is, double click on the button home on the lock display screen is no longer apple pay.

    I tried the reboot, hard reboot. Switching allow home button and reboot, hard reboot. Deleting and adding to my credit card. Pretty much everything I can think of.

    Post edited by: underchigga

    Hello

    The double-click feature applies from the lock screen, not the home screen.

    To check that it is always enabled, go to: settings > portfolio & Apple pay > check that double click on the home page button is enabled.

  • Double click on the ios10 lock screen does not display Apple pay even if it is enabled in the settings

    Double click on the ios10 lock screen does not display Apple pay even if it is enabled in the settings.

    Hello JPMain,

    Thank you for using communities of Apple Support. I understand Apple pay is not an option when the double click the Home button. I know access pay Apple for a locked screen can do so useful everyday. I'm happy to help you to get this resolved with you.

    I recommend first restart your iPhone. This can solve many unexpected behaviours. Follow the steps below if necessary.

    1. Press and hold the sleep/wake button until the Red slider appears.
    2. Drag the slider to turn off your device completely off.
    3. Once the device turns off, press and hold the sleep/wake button again until you see the Apple logo.

    Restart your iPhone, iPad or iPod touch

    If the problem persists, the next option would be to reset all settings. It takes all the defaults, including passwords and Wi - Fi networks, alerts, notifications, brightness, wallpaper and sounds. This will also remove your cards Pay of Apple. Even if no content is lost with this step, it is always a good idea to back up first. If you do not have a recent backup, use the following link for assistance if necessary.

    The backup of your iPhone, iPad and iPod touch

    Once you have correctly saved, reset all settings in settings > general > reset > reset all settings.

    Have a great day!

  • Double click on the Home button does not show open applications?

    Why not double click on the Home button shows my open apps? I have an iphone 6Plus, and I want to close some applications that do not work properly.

    Try a forced reboot. Hold down the Home and Sleep/Wake buttons at the same time for about 15 seconds, until the Apple logo appears. You won't lose anything. And then try to click double fast to access the app selector window. Note that these applications are not open. May be best to remove the apps and reinstall, but try the above first.

    On multitasking on your iPhone, iPad and iPod touch - Apple Support

  • Double click on the arrow to the left on the tab bar creates a new tab at the end of the right hand.

    With Firefox 29.0.1 by double clicking on the arrows on the right in the tab bar or the left creates a new tab at the end of the right hand of the tab bar. It is embarrassing behavior that violates standards around UI design click and double-click. A double-click should extend the behavior of the single click rather than do something completely different (opening a new tab). An example would be, in a Word, a single click selects a Word, double click selects the sentence and a triple click selects the paragraph. Note that this is a separate issue from double click the tab bar itself to create a new tab.

    When there are more tabs on the tabs in the window toolbar, that highlight the tabs on the side will not hold show tab in use. I can click on the left and right arrows at the end of the tab bar to scroll the bar in this sense to bring a tab I want to select in the display. I believe that the double click on the arrow to the left would scroll the bar completely to the right, exposing the tab on the left Double click on the right arrow would scroll the bar left entirely exposing the rightmost tab.

    It is a logical extension and expected behavior of single click. Single click - scroll once (seems to be the value of the tab in three), double-click on - scroll all the way.

    For now, if I want to access the tab on the left, I have to click the arrow slowly and carefully until I get to it. I used only one quick click on the arrow to the left until that shponkah stop scrolling without having to count how many clicks. It is possible that my simple quick clicks were actually double-click. However, the bar tabs would stop scrolling when it reaches the end.

    Now, the behavior is really annoying and unexpected. Double click on left dead entirely right tabs completely left arrow and creates a new tab at the end of the right hand. Ditto the arrow right in the opposite direction.

    While I can (maybe) see that the value of a double click on the tab bar itself to create a new tab, double click on one of the scroll arrows should show a new tab.

    Double click on the arrows of the tab should scroll the tab fully for this purpose bar. If the tab bar is already entirely Scrolls towards ending extra clicks (single, double and triple...) should be ignored.

    I like the idea of opening a new tab to the right of the one that has the focus. This should be an option of the contextual right click menu.

    That should not occur if you click the scroll buttons in the tab bar.
    A double-click should act as page up/down and move a full screen and a triple click should move to the left (first tab) or the right (last) until now tab.

    Start Firefox in Safe Mode to check if one of the extensions (Firefox/tools > Modules > Extensions) or if hardware acceleration is the cause of the problem.

    • Put yourself in the DEFAULT theme: Firefox/tools > Modules > appearance
    • Do NOT click on the reset button on the startup window Mode safe
  • In Firefox updated, my new bookmarks (Favorites) do not appear in Unsorted Bookmarks... or anywhere... and are not for editing when I double-click on the star.

    Used Firefox (and Xmarks) for many years without problem.
    Since the upgrade to the latest version of Firefox, I can't create new bookmarks. When I have a Web page 'star', it does not appear in the folder of Unsorted Bookmarks OR at the bottom of my list of unsorted bookmarks. I'm unable to 1) find my bookmark ANYWHERE and 2) double click on the star to change my bookmark.
    Why am I having this problem? I spent too much time quite several times now trying to figure out what was once a task fundamental, almost blind.
    Thanks for any help you can provide.

    You can check for problems with the database places.sqlite file in the Firefox profile folder.

  • How to delete favorites at the top of my calculation? I double click on the yellow star and it gives me an option to delete it but then when I click on the arrow to the right of the yellow star, that the web page is displayed again?

    Upward at the top where you put in the web site that you are looking so that it stores. I double click on the yellow star and it gives me an option to remove this site. However I can't do something just because it is not delete it.

    Hi SKennedy1311,

    There are several ways you can remove sites the location bar AutoComplete drop-down. It is probably easier for you to see than to explain. Take a look at the Awesome Bar - find your Firefox bookmarks, history, and the tabs in the address bar. This article will give you all the information you need.

    Hope this helps!

  • I'm on windows 7 64 bit, and when I try to save a site by double clicking on the icon star on the address bar, bookmark box flickers power on and off and disappears later

    I'm on windows 7 64 bit and when I try to save a site by double clicking on the icon star on the address bar, bookmark box flickers power on and off and then disappears. I did some research and found that the default theme is the cause. I installed a different theme and the problem goes away and that's why I don't know the root cause. Anyone with ideas on how to solve this problem? I like the default theme!

    Try to uncheck the box next to 'use acceleration hardware when available' in the Options. Worked for me!

  • After I restart my iMac and double-click on the hard drive, a pop up appears with this message: 'the 'Hard drive' file cannot be opened because you don't have permission to view its contents.'.  What is the problem?

    After I restart my iMac and double-click on the hard drive, a pop up appears with this message: 'the 'Hard drive' file cannot be opened because you don't have permission to view its contents.'.  What is the problem?

    Is the name of an external drive or internal one?

  • Re Windows XP: At the opening of the hearts, the window is very small. How can I increase the window to fill the screen. Double click on the top panel does not work.

    Re Windows XP: At the opening of the hearts, the window is very small.   How can I increase the window to fill the screen.   Double click on the top panel does not work.

    Hi Rosa,.

    The size of the window for Hearts is actually design in Windows XP.

    However, there is a solution. You can follow these steps:


    Step 1

    a. first of all, copy the game.

    b. click Start, all programs, games.

    c. right-click on the game of hearts .

    d. Select Properties from the list.

    e. press the button find the target on the next window.

    f. right click on the highlighted file and select copy.

    g. then paste the copy on your desktop.

    h. right click on your desktop.

    i. Select Paste from the list.

    Step 2

    Finally, we will change the resolution for the game setting:

    a. right click on the game you just pasted on your desktop.

    b. Select Properties from the list and click the Compatibility tab.

    c. put the check box marked "run in 640 x 480 screen resolution.

    d. now whenever you want to play, click on that game on your desktop and it opens in mode full screen using the widest possible cards and numbers.

    Hope the helps of information.

  • An alternative to a double click on the time when you need to consult a calendar

    Sometimes, I need to look at a calendar for some reason any. I usually double-click the clock to browse a.

    However, I am on a computer not my own where I limited access privileges. When I double-click on the clock, I get a message "you don't have the proper privilege level to change the system time.

    Is there another similar calendar built into Windows or Microsoft Office 2007 that I use when I am a simple user and cannot double-click on the clock? I do not have to install any software.

    The system that I had in mind is using Windows XP Professional. I don't have access rights to install software. However, I discover that I am able to run sol.exe to my flash drive. Apparently I can run executables as long as they don't need admin powers to install or run.

    I have not polled enough to discover the limits of what I can and cannot do with the software on my flash drive.

  • not be able to double-click on the descktop icons

    I have vista. The computer has a virus, but I used norton to stop him. Everything is back to normal, except that I'm not able to double-click on the icons of desk top of the page and go to my programs. Is there an easy fix for this? Thank you, Don

    Hello


    Method 1:
    Diagnose and automatically repair Windows files and folders problems http://support.microsoft.com/mats/windows_file_and_folder_diag/
    Method 2:
    Start the computer in safe mode and check if the problem persists. Visit the given link and follow the steps to start safe mode.
    http://Windows.Microsoft.com/en-us/Windows7/start-your-computer-in-safe-mode
     
    Method 3:
    You can try to start clean boot your system and check if the problem is related to the software.
    Put your boot system helps determine if third-party applications or startup items are causing the problem. If so, you need to maybe contact the manufacturer of the program for updates or uninstall and reinstall the program.
     
    See the following article in the Microsoft KB for more information on how to solve a problem by performing a clean boot in Windows Vista or Windows 7:
     
    http://support.Microsoft.com/kb/929135
     
    Note:
    After troubleshooting, be sure to set the computer to start as usual as mentioned in step 7 in the above article.
  • music file will not play in second hard drive double click Error "" the requested operation requires a rise ".

    Original title: music file won't play second hard drive by double click.

    Windows 7 ultimate/64

    I have a second hard drive on which I store my music files. If I open a player (Foobar is what I use now) and open the music file in the program, he plays very well, since the second HD.

    But if I double click on the music file (.mp3, usually), I get the message:

    "The requested operation requires a rise."

    I think it should open in the player by default when I do that.

    I remember well, it wasn't the case when I started to use this computer (it's fairly new), while something might have changed.
    I have the .mp3, .wav etc all default extensions for the Foobar player program.

    I went through elaborate measures to appropriate the entire disk and have granted full permissions for me as a user, following to the letter one of the many sites of the detailed instructions for this operation. But there is no help in sight.
    Original title: music file won't play second hard drive by double click

    So I can let my reader opens a music file leave a second drive, but I can't call him by double click or click right/context citing the player. When I do that, nothing happens, but I don't get the message "requires a rise."

    Every time I think that I am getting to know Windows 7, something like this happens. Avoid to receive life dull, of course.

    Thanks a lot for your suggestions. I've pretty much exhausted my own attempts.

    Jack

    Update: I think I've solved the problem. I have no idea that what caused it, but here's what fixed it:

    1 uninstalled Foobar with usual Control Panel uninstall
    2A through the startup disk everything and delete folders or files with the name "foobar" in them.
    3 did the same for the registry (creating a point of restoration first, of course)
    4 restarted
    5 download and install Foobar.

    Yes.

    Works very well.

    A big thank you to all who responded.

    Jack

Maybe you are looking for

  • Where can I find tips on how to put a lot of my documents on my desk in shirts?

    Where can I find tips on how to place the documents saved on my desktop in folders of files?

  • Microsoft Office 2013 is compatible with "Works for Windows.

    My new pc is Windows 8.1 Desktop, HP Pavilion 500 series.  My aging XP pc has work for installed Windows I used since 2000 and who has all my files and a very useful database. This has been used for the execution of a small family business and all fi

  • Satellite Pro A60 does not recognize DVD-R blank disc

    Can anyone help? I've tried several brands of DVD - R, but also blank discs DVD + R on my Satellite Pro A60, but very few of them are even recognized. Pioneer DV - RW DVR - K13A is supposed to work correctly when I check the Properties tab. I tried t

  • DAQ Assistant as a selector of case

    Hello I'm reading an entry to my daq assistant digital camera, and then to hold for x number of seconds, up to that time. The entrance to the wizard matter not after the first entry. So, I used a switch case and started trying with a virtual switch.

  • Problems of the icon

    When I tried to download a portable manual asked me to use Adobe, which I did and then almost all the icons on the PC showed like Adobe. I managed to change this in internet explorer, but it means that everything I try to access ends on e lnk which i