<?xml version="1.0" encoding="utf-8"?> <mx:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="300" layout="vertical" showCloseButton="true" close="closeMe()" > <fx:Script> <![CDATA[ import mx.managers.PopUpManager; protected function closeMe():void{ PopUpManager.removePopUp(this); } protected function moveWindow(location:String):void{ var newX:Number = 0; var newY:Number = 0; var padding:Number = 10; if(location== "center"){ PopUpManager.centerPopUp(this); return; } if(location.indexOf("bottom") >-1) {newY=(parent.height - this.height )- padding;} if(location.indexOf("top") >-1) {newY= padding;} if(location.indexOf("left") >-1) {newX= padding;} if(location.indexOf("right") >-1) {newX=(parent.width - this.width )- padding;} move(newX,newY);//移动弹窗位置 } ]]> </fx:Script> <s:HGroup width="100%"> <s:Button label="Top left" width="100%" click="moveWindow('topleft');"/> <s:Button label="Top right" width="100%" click="moveWindow('topright');"/> </s:HGroup> <s:VGroup width="100%"> <s:Button label="Bottom left" width="100%" click="moveWindow('bottomleft');"/> <s:Button label="Bottom right" width="100%" click="moveWindow('bottomright');"/> </s:VGroup> </mx:TitleWindow>
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="900" height="1000" backgroundColor="#ff00ed" > <mx:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="300" layout="vertical" showCloseButton="true" close="closeMe()" > <fx:Script> <![CDATA[ import mx.managers.PopUpManager; protected function closeMe():void{ PopUpManager.removePopUp(this); } protected function moveWindow(location:String):void{ var newX:Number = 0; var newY:Number = 0; var padding:Number = 10; if(location== "center"){ PopUpManager.centerPopUp(this); return; } if(location.indexOf("bottom") >-1) {newY=padding;} if(location.indexOf("top") >-1) {newY= (parent.height - this.height )- padding;} if(location.indexOf("left") >-1) {newX= (parent.width - this.width )- padding;} if(location.indexOf("right") >-1) {newX=padding;} move(newX,newY);//移动弹窗位置 } ]]> </fx:Script> <s:HGroup width="100%"> <s:Button label="Top left" width="100%" click="moveWindow('topleft');"/> <s:Button label="Top right" width="100%" click="moveWindow('topright');"/> </s:HGroup> <s:VGroup width="100%"> <s:Button label="Bottom left" width="100%" click="moveWindow('bottomleft');"/> <s:Button label="Bottom right" width="100%" click="moveWindow('bottomright');"/> </s:VGroup> </mx:TitleWindow> </s:Application>