zoukankan      html  css  js  c++  java
  • Timer计时器 例2

    package {
        import flash.display.Sprite;
        import flash.text.TextField;
        import flash.text.TextFieldType;
        import flash.text.TextFieldAutoSize;
        import flash.utils.Timer;
        import flash.events.TimerEvent;
        import flash.events.Event;
    
        public class Timer_constructorExample extends Sprite {
                private var statusTextField:TextField = new TextField();        
                private var inputTextField:TextField = new TextField();
                private var delay:uint = 30000;
                private var repeat:uint = 3;
                private var myTimer:Timer = new Timer(delay, repeat);
                
            public function Timer_constructorExample() {
                inputTextField.x = 10;
                inputTextField.y = 10;
                inputTextField.border = true;
                inputTextField.background = true;
                inputTextField.height = 200;
                inputTextField.width = 200;
                inputTextField.multiline = true;
                inputTextField.wordWrap = true;
                inputTextField.type = TextFieldType.INPUT;
    
                statusTextField.x = 10;
                statusTextField.y = 220;
                statusTextField.background = true;
                statusTextField.autoSize = TextFieldAutoSize.LEFT;   
    
                myTimer.start(); 
                statusTextField.text = "You have " + ((delay * repeat) / 1000) 
                                     + " seconds to write your response.";
    
                myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
                myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, completeHandler);
    
                addChild(inputTextField);
                addChild(statusTextField);
            }
    
            private function timerHandler(e:TimerEvent):void{
                repeat--;
                statusTextField.text = ((delay * repeat) / 1000) + " seconds left.";
            }
    
            private function completeHandler(e:TimerEvent):void {
                statusTextField.text = "Times Up.";
                inputTextField.type = TextFieldType.DYNAMIC;    
            }
        }
    }
    
    
    方法详细信息
  • 相关阅读:
    【ASP.Net MVC3 】使用Unity 实现依赖注入
    小菜学习设计模式(五)—控制反转(Ioc)
    ASP.NET MVC中使用Unity Ioc Container
    Unity依赖注入使用详解
    单例模式实现
    Oracle书籍资料链接——更新ing
    eclipse设置控制台字体大小
    eclipse——反编译插件
    java.lang.String里面的trim()方法——删除首尾空格
    java关键词整理——思维导图
  • 原文地址:https://www.cnblogs.com/kuailezoe/p/2760558.html
Copyright © 2011-2022 走看看