当前位置: 代码迷 >> Web前端 >> 展示数字时钟
  详细解决方案

展示数字时钟

热度:343   发布时间:2012-11-10 10:48:50.0
显示数字时钟

显示数字时钟

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	
	<mx:Script>   
		<![CDATA[
		
		import mx.formatters.DateFormatter;   
		import flash.utils.Timer;
		import flash.events.TimerEvent;   
		
		private function init():void {   
		var timer:Timer = new Timer(1000);   
		timer.addEventListener(TimerEvent.TIMER, this.resetNow);   
		timer.start();   
		}   
		
		private function resetNow(event:TimerEvent):void {   
		
		// 获取登录时间和日期
		var dateFormatter:DateFormatter = new DateFormatter(); 
		dateFormatter.formatString = "YYYY 年 MM 月 DD 日";
		var time:String = new Date().toLocaleTimeString();
		var date:String = dateFormatter.format(new Date());
		this.date.text = date;  
		this.clock.text = time;
		}   
		
		]]>   
	</mx:Script>
	
	<mx:Style>
		Application {
			font-size: 12;	
		}
	</mx:Style>
	
	<mx:Text id="date" text="" creationComplete="this.init()" x="10" y="20" width="150" top="23"/>
	
	<mx:Text id="clock" text="" creationComplete="this.init()" x="180" y="20" width="150" top="23"/>
	
</mx:Application>
?

?

  相关解决方案