Post updates:
- [December 19th, 2011] added information in the source code to use the PopUpUtils class in Flex 3.x and lower or Flex 4.x and higher (thanks to FlexMaster_Flash for the feedback in the comments)
In Flex, you can create popups easily, but what if you want to get all of them after they’ve already been created? You could keep track of every created popup using a customized function that puts every single instance in an array for example, but what if you’re using a Flex component that simply creates popups in its own way and you cannot keep track of what it creates? Here I’m going to provide a possible solution.
After some debugging, I found out that Flex puts all the popups among the rawChildren in the application’s SystemManager. This is where we can find them. So now that we know where to look, we need a way to distinguish the children that are popups from those that are not (rawChildren does not contain only popups). If we use only components whose base class is the standard UIComponent class (I think this is the case most of the times), there’s an easy way to know if an instance is a popup or not: the isPopUp property of UIComponent.
Whenever we create a new popup that extends UIComponent, the PopUpManager sets the isPopUp property to true. So, all we need to do is loop through the application’s systemManager.rawChildren and check whether we find an UIComponent instance whose isPopUp property is true. In that case, we’ve got an application’s popup.
To demonstrate the concept, I’ve implemented the PopUpUtils class. It simply allows you to get all the popups inside an application instance, to discover if there are visible popups and to close all the popups. Let’s take a look at it. Read the rest of this entry »

Recent Comments