Flex2的数字时钟(转)

本文介绍了一个使用Flash实现的数字时钟程序。该程序通过定时更新机制,实现了实时显示当前时间的功能。具体而言,它利用了Flash的Timer类来每秒触发一次事件,从而更新时间显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天看到老外的一篇blog, 是一个数字时钟程序,这里转发一下
原文 http://www.devilsworkbook.com/workbookroot/2007/03/clock_digital_in_nature_in_fle.html#more

代码如下
xml 代码
 
  1. <mx:Application   
  2.     xmlns:mx="http://www.adobe.com/2006/mxml"   
  3.     layout="absolute">  
  4.   
  5.     <mx:Script>  
  6.         [CDATA[  
  7.             import flash.utils.Timer;  
  8.             import flash.events.TimerEvent;  
  9.               
  10.             private var timer:Timer;  
  11.               
  12.             private function init():void {  
  13.                 this.timer = new Timer(1000);  
  14.                 this.timer.addEventListener(TimerEvent.TIMER, this.resetNow);  
  15.                 this.timer.start();  
  16.             }  
  17.               
  18.             private function resetNow(event:TimerEvent):void {  
  19.                 this.clock.text = new Date().toLocaleTimeString();  
  20.             }  
  21.         ]]  
  22.     </mx:Script>  
  23.   
  24.     <mx:Label id="clock" creationComplete="init()" x="10" y="10" width="147" height="24"></mx:Label>  
  25.   
  26. </mx:Application>  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值