How to check if a menu is displayed
I create a menu with this:
menu = Menu.createMenu(p开发者_如何学JAVAarent, get_entries());
menu.labelField = "@label";
...
menu.show(position.x, position.y);
How can to check if the menu is still displayed?
Listen to the menuHide event of the menu
; it is dispatched when the menu or a submenu is hidden. Inside the event listener, check if event.target == event.currentTarget
. If they are equal, it means that the menu was just hidden - otherwise it means that the menu is still visible, but one of its submenus were just hidden.
menu.addEventListener(MeuEvent.MENU_HIDE, onHide);
private function onHide(e:Event):void
{
if(e.target == e.currentTarget)
trace("The main menu was just hidden");
else
trace("main menu is still visible, the submenu "
+ e.target + " was just hidden");
}
精彩评论