Closing multiple popups in one shot

Here is the short example how to close all popups in one function.

It is very easy, but one rule shoul be followed - all popups shoul implement interface which contains single method.

package {
    import mx.core.IFlexDisplayObject;
    public interface iPopup extends IFlexDisplayObject {
        function closeWindow():void;
    }
}

Here is how you can implement interface from withing component:

<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" title="My Popup" implements="iPopup">

Your TitleWindow component in that case should implement closeWindow() method. Methot shoul be obviously public.

Here is the piece of code which actually closes all opened popups:

private function closeAllWindows():void {
    var popup:iPopup;
    var popupPackage:Array;
    for (var i:Number=0;i<systemManager.popUpChildren.numChildren;i++) {
        if(systemManager.popUpChildren.getChildAt(i) is iPopup) {
            popup = systemManager.popUpChildren.getChildAt(i) as iPopup;
            popup.closeWindow();
        }
    }
}

 

Please make sure that your code which opens popups sets the list in which your popup will be added:

PopUpManager.addPopUp(myTitleWindow, this, true,PopUpManagerChildList.POPUP);

Comments

Or you can just do PopupManager.removePopup(popup) in the loop.

Hi there, I dont know if I am writing in a proper board but I have got a problem with activation, link i receive in email is not working... http://riahut.com/?4905e1f5afc97fea4fed63f0a7e,

Dont know waht to say. Please try one more time.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.
all information is copyright of riahut.com