4 Replies Latest reply on Jan 10, 2010 12:04 AM by iamfuric

    Disabling mouse events

      Hello all.

      I have a Canvas object which contains roughly 20,000 child DisplayObjects read from a database. These child objects are mainly 'Path' objects; a class which extends UIComponent and drawn with the Graphics.lineTo() method. These objects represent various geographical datas, such as railway or highway systems. Creating and displaying them is not a problem, and occurs at a quite reasonable speed.

      However, what is a problem, is that although I am utilizing absolutley no mouse listeners, simply having the cursor over this Canvas object causes the CPU to remain permanently maxed. Note that the mouse is not moving at all; it is simply resting over the Canvas. Moving the cursor off of the Canvas causes the CPU usage to return to zero. What could be the cause of this useless CPU usage? Could it be that low-level mouse handlers are being called in the background which are not apparent to the control itself? If so, is there a way that these could be disabled?

      Assistance of any sort, even if only a shot in the dark, would be greatly appreciated.

      M. Tryczak

      I have attempted to set the mouseChildren and mouseEnabled flags to false for every object along the display tree. The same result was to be observed. I also tried setting the enabled flag to false for each, but the problem still remains.
        • 1. Re: Disabling mouse events

          Did you try to add event listeners for mouse events and simply call stopImmediatePropagation() on them?

          • 2. Re: Disabling mouse events
            mtryczak Level 1
            Thanks for the suggestion. I've tried called the stopImmediatePropogation() method on each of the following events for the main Canvas class, but there is still no change:

            this.addEventListener(MouseEvent.MOUSE_MOVE, mouseStopHandler);
            this.addEventListener(MouseEvent.MOUSE_OVER, mouseStopHandler);
            this.addEventListener(MouseEvent.ROLL_OVER, mouseStopHandler);
            this.addEventListener(MouseEvent.MOUSE_OUT, mouseStopHandler);
            this.addEventListener(MouseEvent.ROLL_OUT, mouseStopHandler);
            this.addEventListener(MouseEvent.CLICK, mouseStopHandler);
            this.addEventListener(MouseEvent.DOUBLE_CLICK, mouseStopHandler);
            this.addEventListener(MouseEvent.MOUSE_DOWN, mouseStopHandler);
            this.addEventListener(MouseEvent.MOUSE_UP, mouseStopHandler);
            this.addEventListener(MouseEvent.MOUSE_WHEEL, mouseStopHandler);
            this.addEventListener(Event.MOUSE_LEAVE, stopHandler);
            this.addEventListener(FlexEvent.CURSOR_UPDATE, flexStopHandler);
            this.addEventListener(FlexEvent.IDLE, flexStopHandler);
            this.addEventListener(FlexEvent.ENTER, flexStopHandler);

            Somehow, it must be something deep within the Flex core.
            • 3. Re: Disabling mouse events
              archemedia Level 4

              You could try to put breakpoints in all possible problem methods in the canvas class itself. Then when hovering your cursor over the canvas, the debugger might open and you can examine which function is causing the problem. In any case, Flex is going through all the canvas' children. You'll have to stop that. So, find out what method is causing the problem and then, override that method in a custom Canvas component to prevent whatever method that's causing the problem to execute.

              • 4. Re: Disabling mouse events
                iamfuric Level 2

                You can override




                public function dispatchEvent(event:Event):Boolean

                dispatchEvent method (undocumented) in you custom Canvas and filter event beeing dispatch (by event type, target and so on...).