zoukankan      html  css  js  c++  java
  • 【原创】flex自动关闭弹窗

    package com.csharper.utils
    {
        import flash.display.Sprite;
        import flash.events.TimerEvent;
        import flash.utils.Timer;
        
        import mx.controls.Alert;
        import mx.core.IFlexModuleFactory;
        import mx.events.CloseEvent;
        import mx.managers.PopUpManager;
        
        /**
         * @Description: 自动关闭弹窗
         * @author csharper
         * @date 2014-04-10  上午10:00:06
         */
        public class FlashAlert 
        {
            private var alrt:Alert;   
            private var alrtTimer:Timer;   
            private var text:String;
            private var title:String;
            private var flags:uint;
            private var parent:Sprite;
            private var time:Number;
            
            public function FlashAlert(text:String="", title:String="", flags:uint=4, parent:Sprite=null,time:Number=1000)
            {
             this.text=text;
             this.title=title;
             this.flags=flags;
             this.parent=parent;
             this.time=time;
             
             this.init();
            }
            
            private function init():void {   
                alrtTimer = new Timer(time, 1);   
                alrtTimer.addEventListener(TimerEvent.TIMER_COMPLETE, removeAlert);   
            }   
            
            public function showAlert():void {   
                alrt = Alert.show(text, title, flags, parent, alrt_close);   
                alrtTimer.reset();   
                alrtTimer.start();   
            }   
            
            private function alrt_close(evt:CloseEvent):void {   
                alrtTimer.stop();  
            }   
            
            private function removeAlert(evt:TimerEvent):void {   
                PopUpManager.removePopUp(alrt);   
            } 
        }
    }


    测试代码如下:

    var alert:FlashAlert=new FlashAlert("请输入关键字","提示",Alert.OK, this);
    alert.showAlert();
    从娃抓起学抓娃
  • 相关阅读:
    C# 线程之间切换
    工厂方法(创建型)
    单例模式(创建型)
    HTTP请求超时
    命令模式
    Asp.Net Core EF Migrations(二)
    Asp.Net Core EF Migrations
    Vue父子组件之间的通讯(学习笔记)
    数组的方法(笔记)
    Vue-router入门
  • 原文地址:https://www.cnblogs.com/javasharp/p/3768029.html
Copyright © 2011-2022 走看看