<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" ... >
<fx:Script>
<![CDATA[
import flash.utils.clearTimeout;
import flash.utils.setTimeout;
import mx.core.FlexGlobals;
import mx.managers.PopUpManager;
import spark.components.Label;
import spark.components.TitleWindow;
private var myTitleWin:TitleWindow;
protected function btnAlert_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
if(myTitleWin!=null){
PopUpManager.removePopUp(myTitleWin);
myTitleWin=null;
}
//先判断myTitleWin是否已创建,是就清除
//否则会不断响应点击事件,不停地打开多个窗体
myTitleWin=new TitleWindow();
myTitleWin.title="xBox One";
myTitleWin.minWidth=200;
myTitleWin.minHeight=300;
var label:Label=new Label();
label.text="I wanna to play xBoxOne";
myTitleWin.addElement(label);
PopUpManager.addPopUp(myTitleWin,
FlexGlobals.topLevelApplication as DisplayObject);
PopUpManager.centerPopUp(myTitleWin);
}
]]>
</fx:Script>
<s:Button id="btnAlert" label="Open Alert"
click="btnAlert_clickHandler(event)"/>
</s:Application>
Button只弹出一个PopUp窗体
最新推荐文章于 2022-06-06 09:41:07 发布