首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

Flex写两个的数目字时钟

2012-11-03 
Flex写两个的数字时钟?xml version1.0 encodingutf-8?mx:Application xmlns:mxhttp://www.adob

Flex写两个的数字时钟

<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" styleName="filletCanvas"> <mx:Script>        <![CDATA[        private var _time:Date;     //日期        private var timer:Timer;    //计数器  /**   * init()   *   * 初始化控件   *   * @param      * @return void      * @author Xueyy<xueyy@tks-it.com.cn>      * @create 2009/02/09   */  public function init():void  {            this.showCurDate();             timer.addEventListener(TimerEvent.TIMER,timeHandler);            timer.start();     }    public function showCurDate():void  {         _time = new Date();         var monStr:String;         var dateStr:String;         var hoursStr:String;         var minutesStr:String;         var secondsStr:String;              var seconds:Number = _time.getSeconds();  //秒   var minutes:Number = _time.getMinutes();  //分   var hours:Number = _time.getHours();      //时   var day:Number = _time.getDay();          //星期   var date:Number = _time.getDate();        //日   var month:Number = _time.getMonth()+1;     //月   var year:Number = _time.getFullYear();    //年                     timer = new Timer(1000);              if (month<10)   {    monStr = "0"+String(month);   }   else   {    monStr = String(month);   }                if (date<10)   {       dateStr = "0"+String(date);   }     else   {    dateStr = String(date);   }             if (hours<10)   {       hoursStr = "0"+String(hours);   }              else   {    hoursStr = String(hours);   }      if (minutes<10)   {       minutesStr = "0"+String(minutes);   }   else   {    minutesStr = String(minutes);   }      if (seconds<10)   {      secondsStr = "0"+String(seconds);   }   else   {    secondsStr = String(seconds);   }         txtDateTime.text = year+"-"+monStr+"-"+dateStr+" "+hoursStr+":"+minutesStr+":"+secondsStr;      //响应每秒更新一次    }       public function timeHandler(evt:TimerEvent):void     {      this.showCurDate();     }          ]]>    </mx:Script> <mx:Text id="txtDateTime" width="180" fontSize="10" height="23" textAlign="left" fontWeight="normal" paddingTop="3"/></mx:Application>

?

?

<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:Script><![CDATA[private var timer:Timer;//时钟private function timeInit():void{         timer = new Timer(1000);           timer.addEventListener(TimerEvent.TIMER, resetNow);  //每秒执行一次resetNow         timer.start();  }private function resetNow(event:TimerEvent):void{         var today:String = dateFormatter.format(new Date());  //当前时间         clock.text = today.toString() + new Date().toLocaleTimeString(); }]]></mx:Script><mx:DateFormatter id="dateFormatter" formatString="YYYY年MM月DD日"/><mx:Label x="354" y="65" id="clock" creationComplete="timeInit()" fontSize="12" textAlign="center"/></mx:Application>
?

热点排行