首页 > flex, flex 控件用法 > flex 3提示框Alert的使用

flex 3提示框Alert的使用

flex 3提示框Alert的使用
这个在程序中经常用到,首先要在程序中引入mx.controls.Alert,调用的是show()函数
一个简单弹出窗 <mx:Button label="Click me"
          click='Alert.show("这是个简单的弹出框",
            "Alert",
            Alert.OK);'
        />
如何弄个复杂的弹出框
    <mx:Button label="Click me"
          icon="@Embed(source='images/button1.jpg')"
          click='Alert.show("你想要继续吗?",
            "请确认!",
             Alert.YES | Alert.NO, this,
             doActionWhenClose, iconSymbol, Alert.YES);'
        />
show(提示信息,标题,Yes按钮,No按钮,关闭时候的事件,引用的图片,执行Yes)
其中iconSymbol是图片资源定义
[Embed(source="images/confirm1.jpg")]
            [Bindable]
            public var iconSymbol:Class;

完整的代码

<?xml version="1.0" encoding="utf-8"?>

<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    viewSourceURL=""
    horizontalAlign="center" verticalAlign="middle"
    width="100%" height="100%"
>
    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.events.CloseEvent;
           
            // 定义图片资源
            [Embed(source="images/confirm1.jpg")]
            [Bindable]
            public var iconSymbol:Class;
           
            // 定义关闭后的事件
            private function doActionWhenClose(evt:CloseEvent):void
            {
                if (evt.detail == Alert.YES)
                {
                    displayUserAction.text
                        = "你选择了YES,继续!";
                }
                else
                {
                    displayUserAction.textrf= "你选择了NO,停止!";
                }
            }
        ]]>
    </mx:Script>
   
    <mx:Panel title="Panel"
        height="35%" width="75%"
        paddingTop="10"
        paddingLeft="10"
        paddingRight="10"
        paddingBottom="10"
    >
        <mx:Label width="100%"
          height="10%"
          textAlign="center"
          id="displayUserAction"
        />

 <mx:Button label="Click me"
          icon="@Embed(source='images/button1.jpg')"
          click='Alert.show("你想要继续吗?",
            "请确认!",
             Alert.YES | Alert.NO, this,
             doActionWhenClose, iconSymbol, Alert.YES);'
        />
    </mx:Panel>

</mx:Application>
如果出现错误没有图片建个images文件夹,放2张图片名称对上就行了

原创文章转载请注明出处:云飞扬IT的blog

本文链接: http://www.ajaxcn.net/archives/192

分类: flex, flex 控件用法 标签: ,
一键分享到:新浪微博分享  分享到网易微博    转贴到开心网  推荐到豆瓣  分享到QQ空间    RSS订阅
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.