Flex用AS3实现带文本框的弹出框

来源:

http://livedocs.adobe.com/flex/3_cn/langref/mx/containers/TitleWindow.html

 

代码:

 

<?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">

    <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>

 

 

 

 

<?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.managers.PopUpManager;
            import mx.containers.TitleWindow;
             import flash.geom.Point;

            private var point1:Point = new Point();
      
            // Open the TitleWindow container.
            // Cast the return value of the createPopUp() method
            // to SimpleTitleWindowExample, the name of the 
            // component containing the TitleWindow container.
            private function showWindow():void {
                var login:SimpleTitleWindowExample=SimpleTitleWindowExample(PopUpManager.createPopUp( this, SimpleTitleWindowExample , true));

                // Calculate position of TitleWindow in Application's coordinates.
                // Position it 25 pixels down and to the right of the Button control.
                point1.x=0;
                point1.y=0;                
                point1=myButton.localToGlobal(point1);
                login.x=point1.x+25;
                login.y=point1.y+25;
             
                // Pass a reference to the TextInput control
                // to the TitleWindow container so that the 
                // TitleWindow container can return data to the main application.
                login.loginName=returnedName;
            }
        ]]>
    </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:Text id="returnedName" text="" width="100%"/>

    </mx:Panel>
</mx:Application>

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值