flex alert.show方法
show()方法public static function show(text:String = "", title:String = "", flags:uint = 0x4, parent:Sprite = null, closeHandler:Function = null, iconClass:Class = null, defaultButtonFlag:uint = 0x4, moduleFactory:IFlexModuleFactory = null):Alert语言版本:ActionScript 3.0产品版本:Flex 3运行时版本:Flash Player 9, AIR 1.1弹出 Alert 控件的静态方法。在 Alert 控件中选择一个按钮或按下 Esc 键时,将关闭该控件。参数text:String (default = "") — 在 Alert 控件中显示的文本字符串。此文本将在警告对话框中居中显示。title:String (default = "") — 标题栏中显示的文本字符串。此文本左对齐。flags:uint (default = 0x4) — Alert 控件中放置的按钮。有效值为 Alert.OK、Alert.CANCEL、Alert.YES 和 Alert.NO。默认值为 Alert.OK。使用按位 OR 运算符可显示多个按钮。例如,传递 (Alert.YES | Alert.NO) 显示“是”和“否”按钮。无论按怎样的顺序指定按钮,它们始终按照以下顺序从左到右显示:“确定”、“是”、“否”、“取消”。parent:Sprite (default = null) — Alert 控件在其上居中的对象。closeHandler:Function (default = null) — 按下 Alert 控件上的任意按钮时将调用的事件处理函数。传递给此处理函数的事件对象是 CloseEvent 的一个实例;此对象的 detail 属性包含 Alert.OK、Alert.CANCEL、Alert.YES 或 Alert.NO 值。iconClass:Class (default = null) — 位于 Alert 控件中文本左侧的图标的类。defaultButtonFlag:uint (default = 0x4) — 指定默认按钮的位标志。您可以指定一个值,并且只能是 Alert.OK、Alert.CANCEL、Alert.YES 或 Alert.NO 中的一个值。默认值为 Alert.OK。按 Enter 键触发默认按钮,与单击此按钮的效果相同。按 Esc 键触发“取消”或“否”按钮,与选择相应按钮的效果相同。moduleFactory:IFlexModuleFactory (default = null) — 此 Alert 应在其中查找其嵌入字体和样式管理器的 moduleFactory。返回Alert — 对 Alert 控件的引用。 <?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" minWidth="955" minHeight="600"> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <fx:Script> <![CDATA[ import mx.controls.Alert; import mx.events.CloseEvent; private function clickHandler(event:Event):void { Alert.show("Do you want to save your changes?", "Save Changes", 3, this, alertClickHandler); } private function alertClickHandler(event:CloseEvent):void { if (event.detail==Alert.YES) status.text="You answered Yes"; else status.text="You answered No"; } private function secondClickHandler(event:Event):void { Alert.buttonWidth = 100; Alert.buttonHeight=100; Alert.yesLabel = "Magenta"; Alert.noLabel = "Blue"; Alert.cancelLabel = "Green"; Alert.show("Select a color:","Color Selection",1|2|8,this); Alert.yesLabel = "Yes"; Alert.noLabel = "No"; } ]]> </fx:Script> <mx:Panel title="Alert Control Example" width="75%" horizontalAlign="center" paddingTop="10"> <mx:Text width="100%" color="blue" textAlign="center" text="Click the button below to display a simple Alert window."/> <mx:Button label="Click Me" click="Alert.show('Hello World!', 'Message');"/> <mx:Text width="100%" color="blue" textAlign="center" text="Click the button below to display an Alert window and capture the button pressed by the user."/> <mx:Button label="Click Me" click="clickHandler(event);"/> <mx:Label id="status" fontWeight="bold"/> <mx:Text width="100%" color="blue" textAlign="center" text="Click the button below to display an Alert window that uses custom Button labels."/> <mx:Button label="Click Me" click="secondClickHandler(event);"/></mx:Panel></s:Application>