用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>
相关文档:
1、ButtonBar组件:
firstButtonStyleName: "mybuttonBarFirstButtonStyle"; //第一个按钮的样式
lastButtonStyleName: "mybuttonBarLastButtonStyle";//最后一个按钮的样式
buttonStyleNa ......
最近几天,一直在研究flex,说句实在的,其中的苦恼不是一句话两句话能说清楚的.没有接触过啊!不过现在总算是把数据库连上了,做出了自己想要的东西.废话少说,现在呢,我就把我做的代码贴出来,给大家看看,多提宝贵意见.
我用的是jdbc的连接方式(hibernate的连接方式我看网上有,所以就不贴出来了)
1.flex代码
<?xml version ......
Frame Rate对Flex程序占用系统资源的分析,我们通过浏览器不同、Frame Rate不同的情况下,系统资源CPU的利用率比较。
Frame Rate的设置:
默认Frame传输速率是24,我们可以这样来设置,mxmlc -defaule-frame-rate 50 HelloWorld.mxml,通过这一语句的设置,
可以使Frame传输速率为5 ......
<?xml version="1.0" encoding="utf-8"?>
<!-- Simple example to demonstrate the Zoom effect. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Style />
<mx:Script>
& ......
根据别人写了类,自己又增加了一部分,贴出来分享
/*获得两个日期之差 */
public static function getDateDiff(startDate:Date, endDate:Date):int
{
var diff:Number = (Number(endDate) - Number(startDate))/(3600000*24);
return diff;
}
/* 获得现在日期 */
public static function getDate() ......