Flex 弹出窗口的例子

TitleWindowApp.mxml
<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;
            
            import org.system.controls.SimpleTitleWindowExample;
            
            private var point1:Point = new Point();

            

            private function showWindow():void {

                var login:SimpleTitleWindowExample=SimpleTitleWindowExample(PopUpManager.createPopUp( this, SimpleTitleWindowExample , true));

                point1.x=myButton.x;

                point1.y=myButton.y;

                point1=myButton.localToGlobal(point1);

                login.x=point1.x+25;

                login.y=point1.y+25;

                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>

SimpleTitleWindowExample.mxml
<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;

           

            public var loginName:Text;

           

            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,Flex,Flash)