首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

Flex4 自定义弹出提示框

2013-12-09 
Flex4 自定义弹出提醒框?xml version1.0 encodingutf-8?s:Application xmlns:fxhttp://ns.adob

Flex4 自定义弹出提醒框

<?xml version="1.0" encoding="utf-8"?><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"    xmlns:s="library://ns.adobe.com/flex/spark"    xmlns:mx="library://ns.adobe.com/flex/mx"   applicationComplete="init()"><fx:Declarations><!-- 非ビジュアルエレメント (サービス、値オブジェクトなど) をここに配置 --></fx:Declarations><fx:Script><![CDATA[import mx.controls.Alert;import mx.events.CloseEvent;[Bindable][Embed(source="assets/bonus.png")]public var bonusIcon:Class;[Bindable][Embed(source="assets/attention.png")]public var attentionIcon:Class;[Bindable][Embed(source="assets/yes.png")]public var yesIcon:Class;[Bindable][Embed(source="assets/no.png")]public var noIcon:Class;public var alert:Alert;protected function init():void{makesure.addEventListener(MouseEvent.CLICK,cmd_makesure);detail.addEventListener(MouseEvent.CLICK,cmd_detail);}protected function thisAlertClose(event:CloseEvent):void{// YES:uint = 0x0001;// NO:uint = 0x0002;// OK:uint = 0x0004;// CANCEL:uint = 0x0008;var result:uint = event.detail;var message:String="";// / 把标签改回初始值,所以这里显示的是默认标签,如想显示标签自定义内容则不修改回默认标签switch (result){case 1:message ="The selected one is :" +Alert.yesLabel;break;case 2:message ="The selected one is :" +Alert.noLabel;break;case 4:message ="The selected one is :" +Alert.okLabel;break;case 8:message ="The selected one is :" +Alert.cancelLabel;break;}Alert.show(message,"Result",Alert.OK,this,null,bonusIcon,Alert.OK);}protected function cmd_makesure(event:Event):void{// 创建一个包含YES,NO选项的提示框Alert.show("Are you sure?","Make sure",Alert.YES|Alert.NO,this,thisAlertClose);}protected function cmd_detail(event:Event):void{Alert.buttonWidth = 150;Alert.okLabel = "Disneyland";Alert.yesLabel = "Kennedy Space Port";Alert.noLabel = "SIx Flags";Alert.cancelLabel = "Marine World";//关于Alert.show传入参数//text:String="", title:String="", flags:uint=4, parent:Sprite=null, (显示文本,标题,选项【YES|NO|OK|CANCEL】,显示提醒框的上一级画面)//closeHandler:Function=null, iconClass:Class=null, defaultButtonFlag:uint=4, (关闭后调用的方法,图标,默认选项)alert = Alert.show("Where do you want to go?","Destination",Alert.OK|Alert.YES|Alert.NO|Alert.CANCEL,this,thisAlertClose,attentionIcon,Alert.YES);alert.height = 150;alert.width = 700;// 把标签改回初始值,防止影响其他提示框运行,。这是一个好习惯Alert.okLabel = "OK";Alert.yesLabel = "YES";Alert.noLabel = "NO";Alert.cancelLabel = "CANCEL";}]]></fx:Script><s:Panel id="mix" verticalCenter="0" horizontalCenter="0" title="Mix" width="450" height="300"><s:VGroup verticalCenter="0" horizontalCenter="0"><s:Button id="makesure" label="Make sure?" /><s:Button id="detail" label="Where to go?"/></s:VGroup></s:Panel></s:Application>

?

热点排行