Posted by: edsyrett | 15 August 2008

PopupButton on a ViewStack doesn’t….

I was reminded today of a bug in the Flex 3.0 SDK that we had to contend with not so long ago. Basically, if you put a PopupButton somewhere on a ViewStack, there is a strong possibility that your Popup won’t (pop up that is…;-D)

It’s a steaming great grillock in the SDK (details here) that has to do with the PopupButton being removed from the Stage. It took me quite a while to find out what the problem was. However, the solution is quite simple – as suggested in the JIRA report, all you need to do is add an event listener for Event.ADDED_TO_STAGE, and in the handler add back in your popup. About the easiest way to achieve this and make sure you only have to fix in one place is to create your own control. We created our own combobox including the fix, and it looks a bit like this…

public class Combobox extends PopUpButton { private var _grid : DataGrid; // Constructor public function Combobox() { super(); // Flex3 hack. This is to reset the popup as it seems to be removed too often addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); } private function onAddedToStage (event:Event):void { if (popUp == null) { popUp = _grid; } } override protected function createChildren():void { super.createChildren(); if (!_grid) { _grid = new DataGrid(); } } }

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: