国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > WEB開發(fā) > 正文

2.11.使用Calendar控件

2024-04-27 13:51:46
字體:
供稿:網(wǎng)友
2.11.1. 問題
你想要允許用戶在一個日歷樣式的控件中選擇日期。
2.11.2. 解決辦法
使用DateField 控件或DataChooser 控件讓用戶選擇日期。
2.11.3. 討論
Flex 框架提供了兩個控件用來實現(xiàn)日歷樣式的功能:DateField 和DateChooser 控件。DateField控件提供了一個TextInput 控件和一個點擊可以打開日歷的日歷圖標。DateChooser,則不同,它提供了一個可視的日歷給用戶操作。下列范例是一個簡單的旅程計算器用來展示兩種類型的控件。用戶使用DateField 選擇開始日期,使用DateChooser 選擇結(jié)束日期。程序會在控件的change 事件觸發(fā)update 事件處理函數(shù)中計算旅途持續(xù)時間。兩個控件的selectedDate屬性會返回用戶選擇的Date 對象。
+展開
-XML
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical">

<mx:Form>
<mx:FormHeading label="Trip Calculator"/>
<mx:FormItem label="Start Date">
<mx:DateField id="startDatechange="update(event)"/>
</mx:FormItem>
<mx:FormItem label="End Date">
<mx:DateChooser id="endDatechange="update(event)"/>
</mx:FormItem>
<mx:FormItem label="Trip Duration (days)">
<mx:Label id="display"/>
</mx:FormItem>
</mx:Form>
<mx:Script>
<![CDATA[
import mx.events.CalendarLayoutChangeEvent;
private static const MILLISECONDS:int = 1000;
private static const SECONDS:int = 60;
private static const MINUTES:int = 60;
private static const HOURS:int = 24;
private function
update(evt:CalendarLayoutChangeEvent):void {
try {
var diff:Number = endDate.selectedDate.getTime()
-startDate.selectedDate.getTime();
// convert the millisecond into days
var days:int =
int(diff/(MILLISECONDS*SECONDS*MINUTES*HOURS));
display.text = days.toString();
}c
catch(ex:Error) {
}
}

]]>
</mx:Script>
</mx:Application>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 大渡口区| 阿拉善盟| 红桥区| 嘉兴市| 句容市| 宝丰县| 连城县| 巴彦淖尔市| 双桥区| 常州市| 夏河县| 河北区| 城步| 根河市| 交口县| 铁力市| 安远县| 清涧县| 赤壁市| 陕西省| 铅山县| 阿荣旗| 石狮市| 偏关县| 茶陵县| 张家口市| 石阡县| 库尔勒市| 栖霞市| 久治县| 巴马| 广州市| 肥城市| 宜兴市| 社旗县| 平顺县| 平舆县| 永德县| 德惠市| 双牌县| 黔西|