3 Replies Latest reply on Aug 17, 2007 4:26 PM by flexPro

    Remove All Popups?

    JayStang Level 1
      Is there a way witht he popup manager to remove all open popups without having to reverence the popup name.

      Example: I have a full flex app with a login system. I also created an idle component that detects if there hasn't been any user interaction after a certain period of time. If the system goes idle it will switches views to the login screen. My problem is if the user has a popup (or a few) open they will remain open when the view switches to the login screen. This also causes some errors to occur do to my session being killed.

      I was hoping for something like, PopUpManager.removeAllPopUps(); ... but of course that would make life too easy :-P. If anyone has any suggestions let me know.

        • 1. Re: Remove All Popups?
          kcell Level 2
          Hi JayStang,

          this sounds like a nice idea.

          I played around with a static class who encapsulate the popupmanager calls and maybe the code can help you as a startup ( the other functions of the popupmanager are missing).

          The class stores the references in an static array, so that the class can remove them. Basically it works but the code is not solid proved (just the idea), cause weekend is near ;)

          best regards and a nice weekend,

          package iwp
          import mx.managers.PopUpManager;
          import mx.core.IFlexDisplayObject;
          import mx.collections.ArrayCollection;
          import flash.display.DisplayObject;

          public class MyPopupManager
          private static var m_arrMyPopUps:Array;

          public function MyPopupManager()


          public static function createPopUp(parent:DisplayObject, className:Class, modal:Boolean = false, childList:String = null):IFlexDisplayObject
          if ( m_arrMyPopUps == null)
          m_arrMyPopUps = new Array();

          var aPopUpWnd:IFlexDisplayObject = PopUpManager.createPopUp(parent, className, modal,childList);


          return aPopUpWnd;

          public static function removeAllPopUps():void
          if ( m_arrMyPopUps == null)
          return ;
          for(var i:int = 0; i < m_arrMyPopUps.length; i++)
          PopUpManager.removePopUp(m_arrMyPopUps );
          • 2. Re: Remove All Popups?
            JayStang Level 1
            This is great! Thank you. I'll start playing with this now! I appreciate the help.

            • 3. Re: Remove All Popups?
              If you're willing to hack the SDK code a bit, this wouldn't be too hard, as all popups are already kept track of in an array of PopUpData objects called popupInfo, which is found in the mx.managers.PopUpManagerImpl. You could add a public method to this class that iterates through the array, removing each item, as desired. Then you'd simply need to add a method to PopUpManager that delegates the work to this method. It'd be pretty easy, but rolling your own wrapper might be a better idea, if only so you won't have to re-integrate your modified SDK code every time Flex is updated.