flex里面的window的封装,留下脚印!

以下demo转子官网:

SimpleTitleWindowExample:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- Simple custom MXML TitleWindow component.
  3.      The TitleWindowApp application displays this component. 
  4.      You cannot run it independently. -->
  5.      
  6. <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" 
  7.     title="Title Window" x="168" y="86">
  8.     <mx:Script>
  9.         <![CDATA[       
  10.             import mx.managers.PopUpManager;
  11.             import mx.controls.Text;
  12.            
  13.             // A reference to the TextInput control in which to put the result.
  14.             public var loginName:Text;
  15.            
  16.             // Event handler for the OK button.
  17.             private function returnName():void {
  18.                 loginName.text="Name entered: " + userName.text; 
  19.                 PopUpManager.removePopUp(this);
  20.             }
  21.         ]]>
  22.     </mx:Script>
  23.     <mx:HBox>
  24.         <mx:Label text="Enter Name: "/>
  25.         <mx:TextInput id="userName" width="100%"/>
  26.     </mx:HBox>
  27.     <mx:HBox>
  28.         <mx:Button label="OK" click="returnName();"/>
  29.         <mx:Button label="Cancel" click="PopUpManager.removePopUp(this);"/>
  30.     </mx:HBox>
  31. </mx:TitleWindow> 
Main.mxml:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- Main application to demonstrate TitleWindow layout container. -->
  3. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  4.     <mx:Script>
  5.         <![CDATA[
  6.        
  7.             import mx.managers.PopUpManager;
  8.             import mx.containers.TitleWindow;
  9.              import flash.geom.Point;
  10.             private var point1:Point = new Point();
  11.       
  12.             // Open the TitleWindow container.
  13.             // Cast the return value of the createPopUp() method
  14.             // to SimpleTitleWindowExample, the name of the 
  15.             // component containing the TitleWindow container.
  16.             private function showWindow():void {
  17.                 var login:SimpleTitleWindowExample=SimpleTitleWindowExample(PopUpManager.createPopUp( this, SimpleTitleWindowExample , true));
  18.                 // Calculate position of TitleWindow in Application's coordinates.
  19.                 // Position it 25 pixels down and to the right of the Button control.
  20.                 point1.x=0;
  21.                 point1.y=0;                
  22.                 point1=myButton.localToGlobal(point1);
  23.                 login.x=point1.x+25;
  24.                 login.y=point1.y+25;
  25.              
  26.                 // Pass a reference to the TextInput control
  27.                 // to the TitleWindow container so that the 
  28.                 // TitleWindow container can return data to the main application.
  29.                 login.loginName=returnedName;
  30.             }
  31.         ]]>
  32.     </mx:Script>
  33.     <mx:Panel title="TitleWindow Container Example" height="75%" width="75%" 
  34.         paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
  35.         <mx:Button id="myButton" label="Click to open the TitleWindow container" 
  36.             click="showWindow();"/>
  37.         
  38.         <mx:Text id="returnedName" text="" width="100%"/>
  39.     </mx:Panel>
  40. </mx:Application>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值