Creates a pop-up with addPopUp() and adds a Button control to that window that closes the window when you click it : PopupManager « Components « Flex






Creates a pop-up with addPopUp() and adds a Button control to that window that closes the window when you click it

Creates a pop-up with addPopUp() and adds a Button control to that window that closes the window when you click it
            

<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->



<!-- containers\spark\MyPopUpButton.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    xmlns:s="library://ns.adobe.com/flex/spark" height="600" width="600">
    <fx:Script>
         
        import spark.components.TitleWindow; 
        import flash.events.*; 
        import mx.managers.PopUpManager; 
        import spark.components.Button; 
        import mx.core.IFlexDisplayObject; 
        // The variable for the TitleWindow container 
        public var myTitleWindow:TitleWindow = new TitleWindow(); 
        // Method to instantiate and display a TitleWindow container. 
        // This is the initial Button control's click event handler. 
        public function openWindow(event:MouseEvent):void { 
            // Set the TitleWindow container properties. 
            myTitleWindow = new TitleWindow(); 
            myTitleWindow.title = "My Window Title"; 
            myTitleWindow.width= 220; 
            myTitleWindow.height= 150; 
            // Call the method to add the Button control to the 
            // TitleWindow container. 
            populateWindow(); 
            // Use the PopUpManager to display the TitleWindow container. 
            PopUpManager.addPopUp(myTitleWindow, this, true); 
        } 
        // The method to create and add the Button child control to the 
        // TitleWindow container. 
        public function populateWindow():void { 
            var btn1:Button = new Button(); 
            btn1.label="close"; 
            btn1.addEventListener(MouseEvent.CLICK, closeTitleWindow); 
            myTitleWindow.addElement(btn1); 
        } 
        // The method to close the TitleWindow container. 
        public function closeTitleWindow(event:MouseEvent):void { 
            PopUpManager.removePopUp(myTitleWindow); 
        } 
      
    </fx:Script>
    <s:Button label="Open Window" click="openWindow(event);" />
</s: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.Center a popup with PopUpManagerCenter a popup with PopUpManager
6.Create a pop-up with addPopUp() method and adds a Button controlCreate a pop-up with addPopUp() method and adds a Button control