package game.view.component.alert
{
import com.greensock.TweenLite;
import flash.display.DisplayObject;
import game.view.component.alert.AlertBtnType;
import game.view.component.alert.AlertCanvas;
import mx.core.Application;
import mx.managers.PopUpManager;
import mx.managers.PopUpManagerChildList;
public class AlertWindow
{
private static var alertCanvas:AlertCanvas = null;
public var func:Function;
public static var detail:String = '';
public static function show(txt:String='',show:int=1,model:Boolean=true,func:Function = null):void
{
if(alertCanvas == null)
{
alertCanvas = new AlertCanvas();
alertCanvas.okBtnShow = true;
alertCanvas.noBtnShow = show==2?true:false;
TweenLite.to(alertCanvas,0.2,{alpha:1});//对弹出框添加滤镜效果
alertCanvas.tips = txt;//将要显示的内容赋给弹出框的tips
alertCanvas.func = func;
var app:DisplayObject = Application.application as DisplayObject;
PopUpManager.addPopUp(alertCanvas, app, model, PopUpManagerChildList.APPLICATION);
PopUpManager.centerPopUp(alertCanvas);
TweenLite.from(alertCanvas,.2,{'alpha':0});
}
}
//移除组件
public static function hide():void
{
if(alertCanvas != null)
{
TweenLite.to(alertCanvas,0.2,{alpha:0});
TweenLite.delayedCall(0.2,function():void
{
PopUpManager.removePopUp(alertCanvas);
alertCanvas = null;
});
}
}
public function AlertWindow()
{
}
}
}
// AlertCanvas 弹出框用用的小组件都是自定义的,可以用adob封装的组件替代
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="235" styleName="alertCanvas"
height="131" xmlns:com="game.view.component.*" xmlns:help="game.help.*">
<mx:Script>
<![CDATA[
import game.help.ResourceHelp;
public var func:Function;
[Bindable]
public var tips:String = "";
[Bindable]
public var noBtnShow:Boolean = false;
[Bindable]
public var okBtnShow:Boolean = false;
private function backFunction(type:String):void
{
if(func != null)
{
func(type);
}
AlertWindow.hide();
}
]]>
</mx:Script>
<help:TextLArea id="txt" text="{tips}" horizontalCenter="0" y="35" fontSize="15" width="190" height="40" borderStyle="none"
backgroundAlpha="0" borderThickness="0" focusAlpha="0" enabled="false" selectable="false" textAlign="center"/>
<mx:HBox width="180" height="30" bottom="22" horizontalCenter="0" horizontalGap="8" horizontalAlign="center" verticalAlign="middle" >
<com:WarButton id="okBtn" styleName="investQDbut" click="backFunction('ok');" visible="{okBtnShow}" includeInLayout="{okBtnShow}"/>
<com:WarButton id="noBtn" styleName="investQXbut" click="backFunction('no')" visible="{noBtnShow}" includeInLayout="{noBtnShow}"/>
</mx:HBox>
</mx:Canvas>