flex 数字时钟

prviate 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());  //当前时间 
     data.text = today.toString(); 
    clock.text = new Date().toLocaleTimeString();   
}   

<mx:DateFormatter id="dateFormatter" formatString="YYYY年MM月DD日> 

<mx:Label x="354" y="65" id="clock" creationComplete="timeInit()" width="93.95" height="20" fontSize="12" textAlign="center"/> 
<mx:Label x="255" y="10" id="data" creationComplete="timeInit()" width="294.95" height="43" fontSize="24" textAlign="center"/>

posted on 2009-08-11 14:53  timo.li  阅读(392)  评论(0编辑  收藏  举报

导航