用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>
相关文档:
经常在Demo中会看到列表,表格等方式来显示数据。当然有时候也需要添加数据到这些列表或者表格中。有很多方式提交,这里展示一个弹出窗口的方式来添加新的数据到DataGrid中。
例子展示:
首先,我们开始建设一个基本的界面结构,一个带有“Notes"标题的Panel,一个DataGrid,以及一个用于提交数据的按钮。
<?xml ......
使用到的as3gif,请到Google去下载
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" xmlns:file="file.*" xmlns:commont="commont.*">
<mx:TitleWindow title="abc" id="ADwindow" width="400" height="283" >
< ......
<?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 source="style/style.css"/>
<mx:Scri ......