windowPupUp.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
title="Title Window" x="168" y="86">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import mx.collections.ArrayCollection;
//public var p:windowMain; //부모형 참조변수 팝업창에서 메인창의 메소드를 사용할때
public var ac:ArrayCollection;
private function returnInfo():void { //3가지 정보 입력후 버튼을 누르면 실행되는 함수
ac.addItem({name:userName.text, phone:userPhone.text, email:userEmail.text});
//p.부모메소드();
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
<mx:HBox>
<mx:Label text="Enter Name: "/>
<mx:TextInput id="userName" width="100%"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="Enter Phone:"/>
<mx:TextInput id="userPhone" width="100%"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="Enter Email: "/>
<mx:TextInput id="userEmail" width="100%"/>
</mx:HBox>
<mx:HBox>
<mx:Button label="OK" click="returnInfo();"/>
<mx:Button label="Cancel" click="PopUpManager.removePopUp(this);"/>
</mx:HBox>
</mx:TitleWindow>
windowMain.mxml
<?xml version="1.0" encoding="utf-8"?>
<!-- Main application to demonstrate TitleWindow layout container. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.managers.PopUpManager;
import mx.containers.TitleWindow;
import flash.geom.Point;
private var point1:Point = new Point();
[Bindable]public var ac:ArrayCollection = new ArrayCollection();
private function showWindow():void {
var login:windowPopUp=windowPopUp(PopUpManager.createPopUp( this, windowPopUp, true));
point1.x=0;
point1.y=0;
point1=myButton.localToGlobal(point1);
login.x=point1.x+25;
login.y=point1.y+25;
login.ac=ac;
//login.p=this;
}
]]>
</mx:Script>
<mx:Panel title="TitleWindow Container Example" height="75%" width="75%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:Button id="myButton" label="Click to open the TitleWindow container"
click="showWindow();"/>
<mx:DataGrid dataProvider="{ac}">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="name"/>
<mx:DataGridColumn headerText="Phone" dataField="phone"/>
<mx:DataGridColumn headerText="Email" dataField="email"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
</mx:Application>