我最终做了什么(从上面的回复中得到灵感)设置了一个超时,让鼠标有时间旅行,然后在该超时处理程序中使用hitTestPoint检查鼠标是否在任一组件上。这里是代码:
private var timeout:uint;
/**
* On mouse out of item renderer set timeout
* */
protected function _mouseOutHandler(event:MouseEvent):void {
if (data.subCategories.length>0) {
timeout = setTimeout(checkToClose, 150);
}
}
/**
* Handles when mouse moves out of drop down
* */
protected function _menuMouseOutHandler(event:MouseEvent):void {
checkToClose();
}
/**
* Check if mouse is out of drop down and category renderer
* */
public function checkToClose():void {
var point:Point;
clearTimeout (timeout);
// check if drop down is open
if (menu.dropDown) {
point = localToGlobal(new Point(mouseX, mouseY));
menu.dropDown.addEventListener(MouseEvent.MOUSE_OUT, _menuMouseOutHandler, false, 0, true);
// check if we are over drop down or category renderer
// if not close dropdown
if (!menu.dropDown.hitTestPoint(point.x, point.y)
&& !hitTestPoint(point.x, point.y)) {
menu.dropDown.removeEventListener(MouseEvent.MOUSE_OUT, _menuMouseOutHandler);
menu.closeDropDown(false);
}
}
}
这就是我要回落。不幸的是,它不会每次都有效。如果一个组或对象是透明的,它将会错过该对象。如果有人使用此方法,则需要检查owner属性以获取组件(不是父项,尽管它们可以相同)。 – 2011-12-27 17:07:00
@ 1。21千兆如果它真的是透明的,那么按钮就会丢失,但是如果你只是在其皮肤上填充一个“Rect”并将它的alpha设置为0,它将会被击中。 – RIAstar 2011-12-27 21:08:50