0

Flex: Mouse Move Event and Slow Rendering

by Deepak Dhakal 4. June 2009 11:12

In flex, if you using Mouse move event to redraw anything .. You might have experienced very slow rendering .

eg:

this.addEventListener(MouseEvent.MOUSE_MOVE, redraw);

and

    public function redraw(anything:Object=null):void{
            //draw something here
                this.graphics.clear();
                this.graphics.lineStyle(3, 0x000000);
                this.graphics.moveTo(startPoint.x, startPoint.y);
                this.graphics.lineTo(endPoint.x, endPoint.y);
                this.scaleTextInput.x = centerPoint.x;
                this.scaleTextInput.y = centerPoint.y;
           
        }

The Above code results very slow rendering ...

Solution:

Use Event.ENTER_FRAME event instead? Although more resource intensive than the mouse move event, you should receive considerably more updates per second, allowing the mouse to appear more responsive to the user:

Eg:

this.addEventListener(Event.ENTER_FRAME, redraw);   instead of 

this.addEventListener(MouseEvent.MOUSE_MOVE, redraw);

and You are good to go ..Happy Flexing

Tags:

Flex

Powered by BlogEngine.NET 1.5.0.7
Original Design by Laptop Geek, Adapted by onesoft