用flex如何显示数字时钟
通过Flex中的Timer可是实现数字时钟的效果,其效果图如下:
实现的代码如下:
<?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>
相关文档:
MyEclipse Flex环境配置详解
MyEclipse Flex的配置之初我们看看缘由:一开始学习使用Flex的时候,我是用的单独的FlexBuilder3,做些纯Flex的应用程序还可以.但是如果要和Java结合在一起使用,即利用FLEX充当一个完整的J2EE系统的WEB层的话,那么单独使用FlexBuilder3和MYECLIPSE是很不方便的,大大影响了开发效率,因此做 ......
1、ButtonBar组件:
firstButtonStyleName: "mybuttonBarFirstButtonStyle"; //第一个按钮的样式
lastButtonStyleName: "mybuttonBarLastButtonStyle";//最后一个按钮的样式
buttonStyleNa ......
Adobe Flex开发与传统的Web开发有很多不同之处。正确的理解和利用这些不同之处,可以帮助我们创建更丰富的用户体验,也可以反过来增加网站的可用性以及浏览和更新速度。Flex还提供了大量的组件和技术库来让Web开发更加轻松——它提供的强大工具要远远超过传统Web 2.0中的异步JavaScript和XML(Ajax)应用。此外, ......