flex Alert

<mx:Canvel xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="578" height="352"
title="Alert Control Example">
<mx:Script>
<![CDATA[
import mx.events.CloseEvent;
import mx.controls.Alert;
/**
* Alert.show(message[, title[, flags[, parent[, clickHandler[, icon[, defaultButton]]]]]])
*
* message 要显示的消息。
* title: Alert 标题栏中的文本。此参数可选;如果省略此参数,则标题栏为空。
* flags: 可选参数,指示要显示在 Alert 窗口中的按钮。默认值为 Alert.OK,它将显示"确定"按钮。
* 在使用多个值时,请用 | 字符分隔各个值。
* 使用以下值中的一个或多个:Alert.OK、Alert.CANCEL、Alert.YES、Alert.NO。
* 您还可以使用 Alert.NONMODAL 指明 Alert 窗口为非模式窗口。非模式窗口允许用户与应用程序中的其它窗口交互。
*
* parent: Alert 组件的父窗口。Alert 窗口会将自己置于父窗口的中心。
* 使用值 null 或 undefined 来指定 _root 时间轴。
* 父窗口必须是 UIComponent 类的子类,并且是作为 UIComponent 的子类的另一个 Flash 组件,
* 或者是作为 UIComponent 的子类的自定义窗口
*
* clickHandler: 单击按钮时广播的 click 事件的处理函数。
* 除了标准的 click 事件对象属性外,还有另一个 detail 属性,
* 该属性包含所单击按钮的标志值(Alert.OK、Alert.CANCEL、Alert.YES、Alert.NO)。
* 此处理函数可以是函数或对象。
*
* icon: 表示要用作图标(显示在警告文本的左边)的库元件的链接标识符的字符串。此参数是可选的。
*
*defaultButton: 弹出时默认选中按钮
* 此参数可以是以下值之一:Alert.OK、Alert.CANCEL、Alert.YES、Alert.NO。
*
* 再高级的应用请自定义,采用继承
*/
private function clickSecond():void{

Alert.buttonWidth = 100;
//这样设置了标签会替换掉默认的文本
Alert.yesLabel="You"
Alert.noLabel="Default onfouce Me";
Alert.show("Are you Sure?","Note",3,this,handler,null,Alert.NO);
}
private function handler(evt:CloseEvent):void{
if(evt.detail==Alert.YES)
txtArea.text="Yes";
else
txtArea.text="No";
}
private function clickThrid():void{
Alert.buttonWidth = 100;
Alert.yesLabel = "YesLable";
Alert.noLabel = "NoLable";
Alert.cancelLabel = "CancelLable";
Alert.okLabel="okLable";
Alert.show("Select a color:","Color Selection",1|2|4|8,this,alertHandler,null);
}
private function alertHandler(event:CloseEvent):void{
switch(event.detail){
case Alert.YES:txtArea.text="Alert.YES-->detail:"+event.detail.toString();break;
case Alert.NO:txtArea.text="Alert.NO-->detail:"+event.detail.toString();break;
case Alert.CANCEL:txtArea.text="Alert.CANCEL-->detail:"+event.detail.toString();break;
case Alert.OK:txtArea.text="Alert.OK-->detail:"+event.detail.toString();break;
default:
txtArea.text="null";
}
}
//Embed 嵌入一张图片的路径
[Embed(source="VisualComponents/icons/BROWSERHINT.png")]
private var iconClass:Class;
private function clickFourth(event:Event):void{
Alert.show("Have a Icom","icon",1,this,null,iconClass,1);
}
]]>
</mx:Script>
<mx:Button x="77" y="30" label="Hello"
click="Alert.show('Hello,NONMODAL','Message',Alert.NONMODAL|2);"/>
<mx:Button x="77" y="94" label="Yes Or No"
click="clickSecond()"/>
<mx:Button x="77" y="148" label="Have Four Button Alert"
click="clickThrid()"/>
<mx:Button x="77" y="207" label="Have a Icon Alert"
click="clickFourth(event)" width="187"/>
<mx:TextArea id="txtArea" x="328" y="118" height="84"/>
</mx:Canvel >


2,alert样式:(放入CSS文件里面)
Alert
{
roundedBottomCorners: false;
borderColor: #6C6D58;
borderThicknessLeft: 1;
borderThicknessTop: 1;
borderThicknessRight: 1;
borderThicknessBottom: 1;
backgroundColor: #28C785;
titleStyleName: alertTitle;
font-size:12;
controlBarStyleName: alertControlBar;
buttonStyleName:alertBtn;
}
.alertTitle
{
color: #9D2828;
}
.alertBtn
{
height:35;
upSkin: Embed(skinClass="ButtonUp");
overSkin: Embed(skinClass="ButtonOver");
downSkin: Embed(skinClass="ButtonDown");
disabledSkin: Embed(skinClass="ButtonDis");
selectedUpSkin: Embed(skinClass="ButtonOver");
selectedOverSkin: Embed(skinClass="ButtonOver");
selectedDownSkin: Embed(skinClass="ButtonDown");
selectedDisabledSkin: Embed(skinClass="ButtonDis");
textRollOverColor: #38FF94;
textSelectedColor: #38FF94;
color: #14FF83;
}
.alertControlBar
{
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值