当前位置: 代码迷 >> Web前端 >> 一个简略窗体位置控制的demo
  详细解决方案

一个简略窗体位置控制的demo

热度:83   发布时间:2012-11-22 00:16:41.0
一个简单窗体位置控制的demo

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
	<mx:Script>
		<![CDATA[
			import components.SimpleTitleWindowExample;
			import mx.managers.PopUpManager;
			 private function showWindow():void {
	                var login:SimpleTitleWindowExample=SimpleTitleWindowExample(PopUpManager.createPopUp( this, SimpleTitleWindowExample , true));
	                var x:Number; 
               		var y:Number; 
	                x=btn.x;
	                y=btn.y+btn.height;
	                login.height = Application.application.height - y;
	                login.width = Application.application.width - x;
	                login.move(x, y); 
            }
		]]>
	</mx:Script>
	<mx:Button id="btn" click="showWindow()"/>
</mx:Application>


<?xml version="1.0" encoding="utf-8"?>
<!-- Simple custom MXML TitleWindow component.
     The TitleWindowApp application displays this component. 
     You cannot run it independently. -->
     
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" 
    title="Title Window" x="168" y="86" status="active" showCloseButton="true" close="PopUpManager.removePopUp(this);" borderAlpha="0.75">

    <mx:Script>
        <![CDATA[       
            import mx.managers.PopUpManager;
            import mx.controls.Text;
           
            // A reference to the TextInput control in which to put the result.
            public var loginName:Text;
           
            // Event handler for the OK button.
            private function returnName():void {
                loginName.text="Name entered: " + userName.text; 
                PopUpManager.removePopUp(this);
            }
        ]]>
    </mx:Script>

    <mx:HBox>
        <mx:Label text="Enter Name: "/>
        <mx:TextInput id="userName" width="100%"/>
    </mx:HBox>

    <mx:HBox>
        <mx:Button label="OK" click="returnName();"/>
        <mx:Button label="Cancel" click="PopUpManager.removePopUp(this);"/>
    </mx:HBox>

</mx:TitleWindow>
  相关解决方案