发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
<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="startDate" change="update(event)"/>
</mx:FormItem>
<mx:FormItem label="End Date">
<mx:DateChooser id="endDate" change="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();
}
catch(ex:Error) {}
}
]]>
</mx:Script>
</mx:Application>
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。