views:

28

answers:

1

In flex, I am using the following code:

mx:HBox id="box1" mouseOver="onBox('box1')" mouseOut="outofBox('box1')" // adding label // closing HBox

onBox adds an image as child of box1:

var crossImage:Image = new Image(); crossImage.source = "cross.png"; crossImage.id = "cross";

box1.addChild(crossImage);

and outofBox removes them.

I believe that image is child of HBox so mouseOut should not be triggered when I hover the mouse over image. But, the moment I hover my mouse pointer over image, mouseOut is trigerred. Why is it so?

+1  A: 

Set the mouseChildren property of the container to false

Robusto
You can remove the mouseChildren property (or set it to true) and add mouseover and mouseout events to your crossImage. Give them both the same event handler that does the following: `event.stopPropagation(); event.preventDefault();`
Robusto
it did not work. Im not sure if mouse out event ( of container ) wont be called before the events for the image
Found the following answer to my solution: http://stackoverflow.com/questions/557028/how-to-stop-mouse-out-event-on-flex-canvas-firing-for-child-elements