文章分类 Classification
Flex3.0入门课程:如果设置Alert对话框
稿件来源: 阳光企业网站管理系统 撰稿作者: 太阳光 发表日期: 2013-09-16 阅读次数: 72 查看权限: 游客查看
《Flex 3.0入门指南》郝刚 编著
Alert_info.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" fontSize="12"> <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.events.CloseEvent; [Embed(source="alert.gif")] [Bindable] public var iconSymbol:Class; private function showBasic():void { Alert.show(myInput.text,"Alert对话框",Alert.OK); } private function getUser():void { Alert.show("您的选择是","用户选择",Alert.OK|Alert.CANCEL,this,alertClickHandler); } private function alertClickHandler(event:CloseEvent):void { if(event.detail == Alert.OK){ lb1.text = "OK"; }else{ lb1.text = "CANCEL"; } } private function showStyle():void { Alert.buttonWidth=100; Alert.yesLabel="Green"; Alert.noLabel ="Red"; Alert.show("请选择以下颜色:","颜色选择",Alert.YES|Alert.NO,this,backFun,iconSymbol); } private function backFun(event:CloseEvent):void { var alert:Alert; if(event.detail == Alert.YES) alert =Alert.show("Green","提醒"); else alert =Alert.show("Red","提醒"); alert.addEventListener(MouseEvent.MOUSE_DOWN,stop_move,true); } private function stop_move(evt:MouseEvent):void { evt.stopImmediatePropagation();//阻止冒泡 阻止事件侦听 从而阻止拖动alert } ]]> </mx:Script> <mx:Panel width="300" height="240" layout="absolute" title="设置Alert对话框" horizontalAlign="center"> <mx:VBox x="20" y="11" width="240" height="100%"> <mx:HBox width="100%"> <mx:Label text="(1)显示基本Alert对话框"/> </mx:HBox> <mx:HBox width="100%"> <mx:Spacer width="30"/> <mx:TextInput id="myInput" text="请输入内容" width="120"/> <mx:Button label="确定" id="btn1" click="showBasic();"/> </mx:HBox> <mx:HBox width="100%"> <mx:Label text="(2)获取用户选择"/> </mx:HBox> <mx:HBox width="100%"> <mx:Spacer width="30"/> <mx:Button label="单击按钮" id="btn2" click="getUser()"/> <mx:Label id="lb1" color="red"/> </mx:HBox> <mx:HBox width="100%"> <mx:Label text="(3)设置对话框外观" /> </mx:HBox> <mx:HBox width="100%"> <mx:Spacer width="30" /> <mx:Button id="btn3" label="显示Alert对话框" click="showStyle();" /> </mx:HBox> </mx:VBox> </mx:Panel> </mx:Application>
后记:文件名也会影响代码执行,因初学时把以上代码存为Alert.mxml造成代码提示错误,开始让人“百思不得骑姐”
关键词: Flex3.0,入门课程,alert 编辑时间: 2013-09-16 14:45:47
0
高兴0
支持0
搞笑0
不解0
谎言0
枪稿0
震惊0
无奈0
无聊0
反对0
愤怒
0%(0)
0%(0)
- 暂无评论
文章图片 article Pictrue
网友评论