大致就是分两步:
(1)先自定义窗体的布局mxml文件showHistoryStatics 比如:
<mx:Panel title="停车场信息" textAlign="center" width="100%" height="50%" minHeight="10"
dropShadowVisible="false" borderColor="#99bbe8" color="#0000FF">
<s:Group width="100%" height="4">
<s:Line horizontalCenter="0" width="100%">
<s:stroke>
<s:SolidColorStroke color="#FF8C40" weight="4" caps="square"/>
</s:stroke>
</s:Line>
</s:Group>
<s:HGroup width="100%" height="30" verticalAlign="middle" horizontalAlign="center">
<s:Label text="停车场编号:"/>
<s:TextInput editable="false" text="{}"/>
<s:Label text="停车场名称:"/>
<s:TextInput editable="false" text="{str_time}"/>
</s:HGroup>
<s:HGroup width="100%" height="30" verticalAlign="middle" horizontalAlign="center">
<s:Label text="停车场类型:"/>
<s:TextInput editable="false" text="{str_code}"/>
<s:Label text="停车场地址:"/>
<s:TextInput editable="false" text="{str_code}"/>
</s:HGroup>
<s:HGroup width="100%" height="30" verticalAlign="middle" horizontalAlign="center">
<s:Label text="经营单位名:"/>
<s:TextInput editable="false" text="{str_code}"/>
<s:Label text="总车位个数:"/>
<s:TextInput editable="false" text="{str_code}"/>
</s:HGroup>
</mx:Panel>
接着要在主窗体中显示:
var add_window:showHistoryStatics=new showHistoryStatics();
add_window.title="停车场统计信息";
PopUpManager.addPopUp(add_window,this,true);
PopUpManager.centerPopUp(add_window);
但是只有以上两句有些时候在多层窗口里是不能居中显示的,原因不明
所以要自己手动设定,让其剧中,加上如下两句即可
add_window.x=Capabilities.screenResolutionX/2-add_window.width/2;
add_window.y=Capabilities.screenResolutionY/2-add_window.height/2;
其中
Capabilities.screenResolutionX
Capabilities.screenResolutionY
分别是获取当前屏幕的宽高
获取当前窗体的宽高为
add_window.width/2;
add_window.height/2;
或者直接是
this.height;
this.width;