5 Replies Latest reply on Jan 29, 2010 1:24 PM by Francisc

    Click order

    Francisc Level 3



      I have a canvas and an image in that canvas.

      The image has a click event associated with it.

      The canvas has a doubleClick event associated with it.


      How can I make it that if the IMAGE is double-clicked, the canvas does not dispatch the double-click event as it if was done over it directly?


      Thank you!

        • 1. Re: Click order



          You can check the event.curentTarget in the double-click handler function and if the object found is your canvas, do something. Otherwise (the object is your picture) do nothing. Make sure to call event.stopPropagation() at the end of the handler function.



          • 2. Re: Click order

            One possible way with which i was able to suppress the double click event in canvas was by retreiving the area in the layout over which your image is laid.. and adding it in if condition in the doubleclick handler for the canvas doubleclick listener..


            you can use this code..


            public function doubleclickhandler(evt:MouseEvent):void{
                            if((mouseX>img.x && mouseY>img.y)&& (mouseX>img.x && mouseY<(img.y+img.height)) && (mouseX<(img.x +img.width) && mouseY>(img.y)) && (mouseX<(img.x +img.width) && mouseY<(img.y+img.height)))
                            {Alert.show("No double click on canvas");
                            Alert.show("double click handled");


            the condition in the if is actually the area of the image..


            It is working for me. Hope it does for you too.

            • 3. Re: Click order
              Francisc Level 3

              I thought of those two, but if there are lots of items on the surface that is to be double-clicked there are a lot of listeners to be added.


              I was wondering if there is an easier way.

              • 4. Re: Click order
                Dazed&Flashed Level 1

                what is your purpose for double click on canvas?? Just

                curious if taht can be solved.


                Otherwise you can try removing the double click eventlistener on canvas when you hover over the elements in the canvas and in the hover events you can add the createlistener of click as in case of image. In the similar way for other elements.

                • 5. Re: Click order
                  Francisc Level 3

                  If removing the double click was an option, I would have removed it before asking, but sadly it is not the case.


                  I use the double-click to Maximize the application. The Canvas in questions acts like the top bar of a window.