Flex系统自带的Alert组件是没有图片,提示信息还是英文的,使用起来很不方便,下面是经过封装后的Alert:
package cn.ccb.yn.acms.actionscript
{
import mx.controls.Alert;
import mx.controls.Tree;
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
import mx.rpc.events.ResultEvent;
import spark.components.BorderContainer;
import spark.components.Button;
import spark.components.TitleWindow;
public class MyAlert
{
[Embed(source='./assets/icon-info.gif')]
public static var iconInfo:Class;
[Embed(source='./assets/icon-error.gif')]
public static var iconError:Class;
[Embed(source='./assets/icon-warning.gif')]
public static var iconWarning:Class;
[Embed(source='./assets/icon-question.gif')]
public static var iconQuestion:Class;
public function MyAlert()
{
}
public static function showInfo(str:String):void
{
Alert.yesLabel="确定";
Alert.cancelLabel="取消";
Alert.show(str,"提示",Alert.YES,null,null,iconInfo);
}
public static function showWarning(str:String):void
{
Alert.yesLabel="确定";
Alert.cancelLabel="取消";
Alert.show(str,"提示",Alert.YES,null,null,iconWarning);
}
public static function showError(str:String):void
{
Alert.yesLabel="确定";
Alert.cancelLabel="取消";
Alert.show(str,"错误",Alert.YES,null,null,iconError);
}
public static function confirm(str:String,obj:Function):Object
{
Alert.yesLabel="确定";
Alert.cancelLabel="取消";
return Alert.show(str,"警告",Alert.YES|Alert.CANCEL,null,obj,iconQuestion);
}
public static function resultInfo(event:ResultEvent,sucMsg:String,failMsg:String,fuc:Function):void{
var msg:String = event.result.toString();
if(msg=="success"){
MyAlert.showInfo(sucMsg);
fuc();
return;
}
MyAlert.showInfo(failMsg);
}
public static function closeWnd(wdm:TitleWindow):void{
PopUpManager.removePopUp(wdm);
}
}
}resultInfo是一个回调函用函数,提示信息出现确认和取消的时候,当用户选择了确认按钮执行的操作。





