Aaron
Aaron

Reputation: 177

How can I stop a parent from dispatching a MOUSE_OUT event when mousing over its child?

I have a parent sprite containing a child named controlBar, whose visibility is initially set to false. When the parent sprite is moused over, controlBar's visibility is set to true, and when the parent sprite is moused out, controlBar's visibility is set to false again, like so:

private function mouseOutHandler(e:MouseEvent):void
{
    controlBar.visible = false;
}

private function mouseOverHandler(e:MouseEvent):void
{
    controlBar.visible = true;
}

This works fine when mousing over and out of the parent sprite, but then when I mouse over the controlBar, the parent sprite dispatches the MOUSE_OUT and MOUSE_OVER events again, which quickly sets controlBar's visibility to false and then true, and occasionally causes controlBar to flicker. This is exacerbated when mousing around in controlBar, because it contains four spaced-apart buttons, and the parent sprite dispatches MOUSE_OUT and MOUSE_OVER events when mousing from one button to another.

What's a simple way to stop the parent sprite from dispatching a MOUSE_OUT event when mousing over its child controlBar?

Upvotes: 0

Views: 287

Answers (1)

zzzzBov
zzzzBov

Reputation: 179086

You should be using MouseEvent.ROLL_OVER and MouseEvent.ROLL_OUT. They'll do what you need.

Upvotes: 3

Related Questions