`
annewman
  • 浏览: 30075 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Flex 之 初学 Alert 控件

    博客分类:
  • Flex
阅读更多

Alert 控件 常用方法 show

    参数列表

Alert.show(content,title,flags,parent,closeHandle,iconClass,defaultButtonFlag);

   参数讲解

   content:提示文本

   title:提示标题

   flags:出现的按钮

  parent:显示的参照对象,一般都用this

  closeHandle:回调函数

  defaultButtonFlag:默认被选中的按钮,也就是回车时默认执行的按钮

 

实例演示:

     实例一:简单提示框

             <mx:Label x="36" y="10" text="简单的提示框" width="80" height="18" fontSize="11"  fontWeight="bold" olor="#FC0202"/>
  <mx:Button x="51" y="46" label="显示" width="56" id="btn1" click="mx.controls.Alert.show('你好啊','提示')"     fontWeight="bold" color="#000000"/>

    

       实例二:有选择的提示框

    

<mx:Script>
 
  <![CDATA[
  import mx.controls.Alert;
  import mx.events.CloseEvent;  
  
   //弹出附带可选按钮的提示框
  private function clickHandler(event:Event):void {
          mx.controls.Alert.show("是否要保存更改?", "保存更改",3, this, alertClickHandler);
   } 
   //回调方法,以显示被选按钮

   private function alertClickHandler(event:CloseEvent):void {
         if (event.detail==mx.controls.Alert.YES)
                status.text = "你选择了 Yes";
         else
                status.text = "你选择了 No";
    }
  ]]>
 </mx:Script>

 

<mx:Label x="36" y="85" text="含有可选按钮的提示框" width="126" color="#F70B06" fontWeight="bold" />
  <mx:Button x="51" y="123" label="显示" width="56" id="btn2" color="#000000" click="clickHandler(event)"/>
  <mx:Label x="10" y="167" id="status" text="结果显示" color="#F70B06" fontWeight="bold"/>

 

实例三:自定义显示按钮

 

              

    private function customButtonClickHandle(event:Event):void{
    mx.controls.Alert.buttonWidth = 100;
    mx.controls.Alert.yesLabel = "OK";
    mx.controls.Alert.noLabel = "No";
    mx.controls.Alert.cancelLabel = "Cancel";
    mx.controls.Alert.show("你好啊","提示信息",1|2|8,this,customButtonCloseEvent);
    //恢复默认
    mx.controls.Alert.buttonWidth = 60;
    mx.controls.Alert.yesLabel = "Yes";
    mx.controls.Alert.noLabel = "No";
   }
    private function customButtonCloseEvent(event:CloseEvent):void{
     if(event.detail == mx.controls.Alert.YES)
       status2.text = "您选择了OK";
      else{
       if(event.detail == mx.controls.Alert.NO)
        status2.text ="您选择了NO";
       else
         status2.text = "您选择了cancel";
      }
    }

              

 

<mx:Label x="36" y="193" text="含有自定义按钮的提示框" width="141" color="#F70B06" fontWeight="bold"/>
  <mx:Button x="51" y="219" label="显示" width="56" id="btn3" color="#000000" click="customButtonClickHandle(event)"/>
  <mx:Label x="10" y="259" id="status2" text="结果显示" width="106" color="#FA1301" fontWeight="bold"/>

下面附件中带有源码。

   有个问题请高手回答

     为什么我导入了Alert控件的包。Flex builder还是提示找不到,必须写全才不会有找不到的错误

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics