Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop Mouse Out event on Flex Canvas firing for child elements

I am using a Canvas itemRenderer for a container I use to display images. See pseudo code below.

image = new Image();
image.source = data.@thumb;
this.addChild(image);
this.addEventListener(MouseEvent.MOUSE_OVER, enlarge(image));
this.addEventListener(MouseEvent.MOUSE_OUT, shrink(image)); 

When I mouse over the canvas, the enlarge function is called. However as soon as I move the mouse onto the image, or another child element, the MOUSE_OUT event is fired.

Can anyone point me in the direction of a way to disable this behaviour?

Thanks :)

like image 674
adam Avatar asked Dec 01 '22 08:12

adam


2 Answers

You should use MouseEvent.ROLL_OVER and MouseEvent.ROLL_OUT events instead.

From the Flash CS4 documentation:

When the mouse enters the area of a display object or the area of any of its children from an object that is not one of its children, the display object dispatches the rollOver event. This is different behavior than that of the mouseOver event, which is dispatched each time the mouse enters the area of any child object of the display object container, even if the mouse was already over another child object of the display object container.

like image 198
Josh Tynjala Avatar answered Dec 09 '22 09:12

Josh Tynjala


I agree with Josh that the ROLL_OVER events seem more appropriate to what you're doing. However, you should be aware of the mouseChildren property of flash.display.DisplayObjectContainer (an ancestor of UIComponent).

like image 34
Michael Brewer-Davis Avatar answered Dec 09 '22 11:12

Michael Brewer-Davis