今天看到老外的一篇blog, 是一个数字时钟程序,这里转发一下
原文 http://www.devilsworkbook.com/workbookroot/2007/03/clock_digital_in_nature_in_fle.html#more
代码如下
原文 http://www.devilsworkbook.com/workbookroot/2007/03/clock_digital_in_nature_in_fle.html#more
代码如下
xml 代码
- <mx:Application
- xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="absolute">
- <mx:Script>
- [CDATA[
- import flash.utils.Timer;
- import flash.events.TimerEvent;
- private var timer:Timer;
- private function init():void {
- this.timer = new Timer(1000);
- this.timer.addEventListener(TimerEvent.TIMER, this.resetNow);
- this.timer.start();
- }
- private function resetNow(event:TimerEvent):void {
- this.clock.text = new Date().toLocaleTimeString();
- }
- ]]
- </mx:Script>
- <mx:Label id="clock" creationComplete="init()" x="10" y="10" width="147" height="24"></mx:Label>
- </mx:Application>