您的位置:首页 > Web前端 > CSS

Flex更改Alert提示框的字体大小和样式

2010-11-12 16:22 465 查看
1、Alert字体大小更改

先创建一个css文件,这里我取名global.css,路径flex_src/css/global.css

.AlertTitle
{
font-size: 12pt;
font-weight: normal;
font-style: normal;
}
.AlertMessage
{
font-size: 12pt;
font-weight: normal;
font-style: normal;
}

然后编写一个工具类,利用PopUpManager管理一个Alert实例,不再用其静态show方法了,例如:

public static function Prompt(msg:String,parent:DisplayObject):void{
var alert:Alert = new Alert();
alert.setStyle("messageStyleName","AlertMessage");
alert.setStyle("titleStyleName","AlertTitle");
alert.title = "提示";
alert.text = msg;
PopUpManager.addPopUp(alert,parent,true);
PopUpManager.centerPopUp(alert);

}

public static function Confirm(msg:String,parent:DisplayObject,closeHandler:Function){
var alert:Alert = new Alert();
alert.setStyle("messageStyleName","AlertMessage");
alert.setStyle("titleStyleName","AlertTitle");
alert.title = "操作确认";
alert.text = msg;
alert.addEventListener(Event.CLOSE,closeHandler);
alert.buttonFlags = Alert.OK | Alert.CANCEL;
alert.defaultButtonFlag = Alert.OK;
PopUpManager.addPopUp(alert,parent,true);
PopUpManager.centerPopUp(alert);
}

最后在要使用Alert的地方引用该css,

然后就可以调用上面的静态方法Prompt和Confirm弹出提示框和确认框了,想修改字体样式?改css文件就可以了。编写工具类也可以更好的统一整个应用的提示框样式。以上方式经在我的项目中试验,效果刚刚的。

2、采用release模式编译swf文件压缩体积

fb3将release模式编译mxml的功能放到了file -> export -> flex builder -> release build 菜单下,经过测试,我的swf压缩了将近一倍。

3.最新又发现了,只要在应用中添加整个Application的样式,则整个应用默认字体都可以更改了。再回头看看上面的解决之道,觉得确实是麻烦得可以了。

Application {
font-size:12px;
font-style: normal;
font-weight: normal;
}

在样式文件中这样设置就可以了。tooltip alert字体统一设置了。现在,可以直接Alert.show了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: