用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>
相关文档:
我的Flex学习笔记
2009-10-16
问题:Debug不可用,trace无法在Console中输出内容。弹出对话框提示是否重新安装flash player。
解决:安装flashplayer_debug,问题解决。
http://www.java1995.cn/resource/8a8288881fe2c4f8011fe995e4320002
AS3不支持函数重。
问题:this = new Vector2D(),编译错误1050,无法 ......
Adobe Flex开发与传统的Web开发有很多不同之处。正确的理解和利用这些不同之处,可以帮助我们创建更丰富的用户体验,也可以反过来增加网站的可用性以及浏览和更新速度。Flex还提供了大量的组件和技术库来让Web开发更加轻松——它提供的强大工具要远远超过传统Web 2.0中的异步JavaScript和XML(Ajax)应用。此外, ......
Frame Rate对Flex程序占用系统资源的分析,我们通过浏览器不同、Frame Rate不同的情况下,系统资源CPU的利用率比较。
Frame Rate的设置:
默认Frame传输速率是24,我们可以这样来设置,mxmlc -defaule-frame-rate 50 HelloWorld.mxml,通过这一语句的设置,
可以使Frame传输速率为5 ......
mode有三种模式:ProgressBarMode.EVENT,ProgressBarMode.POLLED ,ProgressBarMode.MANUAL ,事件模式和轮询模式是最常用的模式。 在事件模式下,source 属性指定生成 progress 和 complete 事件的加载内容;在此模式下,应使用 UILoader 对象。 在轮询模式下,source 属性指定公开 bytes ......