六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 171|回复: 0

flex Alert

[复制链接]

升级  63.33%

41

主题

41

主题

41

主题

秀才

Rank: 2

积分
145
 楼主| 发表于 2013-2-7 23:42:46 | 显示全部楼层 |阅读模式
<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
{
}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表