flex中倒计时

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/02/15/creating-timers-using-the-settimeout-method/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">
     <mx:Script>
         <![CDATA[
             import mx.controls.Alert;
             public var intervalId:Number;//定时器参数
             private var alert:Alert;
             private function delayedAlert():void {
                 var num:Number;
                 intervalId =setInterval(launchAlert, 1000);

                 button.enabled = false;
                
             }
             private function launchAlert():void {
              
              if(Number(count.text)>0){
                  count.text=String(Number(count.text)-1);
                 }
                
                 if(Number(count.text)==0){
                  
                  alert = Alert.show("I'm an alert.");
                  button.enabled = true;
                  clearInterval(intervalId);
                 }

             }
         ]]>
     </mx:Script>
    <mx:Button id="button"
            label="Click here to launch alert"
            click="delayedAlert();" />
     <mx:TextInput name="count" id="count" text="2" width="32"></mx:TextInput>
</mx:Application>

示例

    A+
发布日期:2009年12月12日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: