package
{
import flash.display.Sprite;
import mx.controls.Alert;
import mx.core.Application;
import mx.effects.Move;
import mx.effects.Parallel;
import mx.effects.WipeUp;
import mx.managers.PopUpManager;
public class KAlert
{
public function KAlert()
{
super();
}
public static function show(text:String,modal:Boolean = false):void{
var alert:Alert = new Alert();
setAppleStyle(alert);
setOpenEffect(alert);
alert.text = text;
var parent:Sprite = Sprite(Application.application);
PopUpManager.addPopUp(alert, parent, modal);
alert.x = Application.application.width/2-100;
alert.setActualSize(alert.getExplicitOrMeasuredWidth(), alert.getExplicitOrMeasuredHeight());
}
//设置弹出窗口样式
private static function setAppleStyle(alert:Alert):void{
alert.setStyle("headerHeight",0);
alert.setStyle("cornerRadius",0);
alert.setStyle("shadowDirection","right");
alert.setStyle("backgroundAlpha","1");
alert.setStyle("backgroundColor","#dfe1e2");
alert.setStyle("color","#333333");
alert.setStyle("borderThicknessLeft","0");
alert.setStyle("borderThicknessRight","0");
alert.setStyle("borderThicknessTop","0");
alert.setStyle("borderThicknessBottom","0");
alert.setStyle("fontSize","12");
}
//设置弹出动画
private static function setOpenEffect(alert:Alert):void{
var wipeUp:WipeUp = new WipeUp(); //Wipe效果,方向向上
var move:Move = new Move(); //移定效果
var parallel:Parallel = new Parallel(); //加入其中的效果会被并发执行
parallel.addChild(move);
parallel.addChild(wipeUp);
//设置弹出框在正中央
move.xFrom = Application.application.width/2-100;
move.xTo = Application.application.width/2-100;
//弹出时从-100移动到100,同时wipeUp
move.yFrom = -100;
move.yTo = -1;
//动画执行时间为300毫秒
wipeUp.duration = 300;
move.duration=300;
//在当前控件被加入舞台时执行
alert.setStyle("addedEffect",parallel)
}
}
}
引自:http://yecon.blog.hexun.com/29488118_d.html