views:

29

answers:

1

I created a Button in MXMXL. On button click, I create a Menu as a child of the Button. I am using an XML datasource. The reason for creating it this way, was due to the amount of custom skinning involved. A popupmenubutton was not an option. Anyway, so my question is this: when clicking the button, the menu is displayed. However, if you click the button again, the menu reopens. I want the menu to close if the user clicks the button a second time. Now, I got it to work by setting a var after opening the menu, and then I check that var on each click to make sure that the menu isn't already open. If true, then it will close the menu, instead of reopening it. This works, until the user clicks away, in which the HIDE event gets dispatched and the menu closes. My hack no longer works.

Any suggestions? I spent hours trying different things. The hardest part is trying to destinguish from that second button click when the menu is open, and when the user clicks away from the menu. They both dispatch the HIDE event.

Help!!!

+1  A: 

Have you tried adding another eventlistener to the button...FlexMouseEvent.MOUSE_DOWN_OUTSIDE ? You should then be able to set the preventDefault event to true to stop the event from firing anything else and stop the menu from closing.

Gareth Arch
I have tried that. Nothing happens because the event.cancelable is false. Any other thoughts?
Dana
Here is how I fixed it:http://stackoverflow.com/questions/3077980/flex-menu-control-click-a-button-and-a-menu-is-displayed-how-can-i-click-that
Dana