Center a popup with PopUpManager : PopupManager « Components « Flex






Center a popup with PopUpManager

Center a popup with PopUpManager
         
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
        import mx.managers.PopUpManager;
        import mx.controls.TextArea;
        import mx.core.IFlexDisplayObject;
        public var myPopUp:TextArea
        
        public function openWindow(event:MouseEvent):void {
            myPopUp = new TextArea();
            myPopUp.width= 200;
            myPopUp.height= 100;
            myPopUp.text = "Hold Shift key and click TextArea to close it.";
            myPopUp.addEventListener(MouseEvent.CLICK, closeWindow);
            PopUpManager.addPopUp(myPopUp, this, true);
            PopUpManager.centerPopUp(myPopUp);
        }
        public function closeWindow(event:MouseEvent):void {
            if (event.shiftKey) {
                label1.text = myPopUp.text;
                PopUpManager.removePopUp(IFlexDisplayObject(event.currentTarget));
            }
        }
      
    </mx:Script>
    <mx:VBox>
        <mx:Button id="b1" label="Create TextArea Popup" click="openWindow(event);" />
        <mx:Label id="label1" />
    </mx:VBox>
</mx:Application>

   
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Using TitleWindow and PopUpManager eventsUsing TitleWindow and PopUpManager events
2.Use PopUpManager to add and remove TitleWindowUse PopUpManager to add and remove TitleWindow
3.Create a TitleWindow with PopUpManagerCreate a TitleWindow with PopUpManager
4.Close a TitleWindow with PopUpManagerClose a TitleWindow with PopUpManager
5.Create a pop-up with addPopUp() method and adds a Button controlCreate a pop-up with addPopUp() method and adds a Button control
6.Creates a pop-up with addPopUp() and adds a Button control to that window that closes the window when you click itCreates a pop-up with addPopUp() and adds a Button control to that window that closes the window when you click it