views:

40

answers:

2

I have a button containing 2 child buttons. I want to be able to keep the mouse over state active, when I rollover a child button. At present it fires mouse out when i rollover a child button, I suspect this is correct, but not what I want to happen.

Any ideas how to get around this?

A: 

Change from mouseOver state to normal state in the MouseEvent.ROLL_OUT handler instead of MouseEvent.MOUSE_OUT handler.

The purpose of the rollOut event is to simplify the coding of rollover behaviors for display object containers with children. When the mouse leaves the area of a display object or the area of any of its children to go to an object that is not one of its children, the display object dispatches the rollOut event. This is different behavior than that of the mouseOut event, which is dispatched each time the mouse leaves the area of any child object of the display object container, even if the mouse remains over another child object of the display object container.

Amarghosh
Thanks for the explanation of the two event types. This now makes complete sense and using the MouseEvent.ROLL_OUT AND ROLL_OVER is exactly what I need.I have also integrated Oliver's suggestion in to this solution to help me to set the state of the parent button when I want to.
Neil
A: 

You can also add the event on both and use stopImmediatePropagation() to prevent mouse out from firing;

More about using stopImmediatePropagation and stopPropagation() here:

http://www.senocular.com/pub/kirupa/as3tips_p6.html

Oliver
Thanks for this, I never find myself needing to cancel and propogation, but this is certainly a time where I need to use this. Thanks for the reminder.
Neil