现在的位置: 首页 > 综合 > 正文

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

2018年03月29日 ⁄ 综合 ⁄ 共 2969字 ⁄ 字号 评论关闭
以下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>

【上篇】
【下篇】

抱歉!评论已关闭.