<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white" fontSize="14" fontFamily="arial">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function a():void{
var year:String;
var month:String;
var day:String;
//label1.text=df.format(dateChooser.selectedDate).toString();
year=dateChooser.selectedDate.getFullYear().toString();
month=(dateChooser.selectedDate.getMonth()+1).toString();
day=dateChooser.selectedDate.getDate().toString();
datetext.text=year+"年"+month+"月"+day+"日";
}
private function init():void{
dateChooser.selectedDate=new Date(2008,7,8);
var newdate:Date=new Date();
datetext.text=newdate.getFullYear().toString()+"年"+(newdate.getMonth()+1).toString()+"月"+newdate.getDate().toString()+"日";
}
]]>
</mx:Script>
<mx:Panel width="236" height="298" layout="absolute">
<mx:DateChooser id="dateChooser" yearNavigationEnabled="true"
headerColors="{[c1.selectedColor, c2.selectedColor]}" creationComplete="init();" click="a()" x="10" y="10"/>
<mx:Label text="当前日期:" y="230" x="11"/><mx:TextInput x="80" y="226" id="datetext" width="126"/>
</mx:Panel>
<mx:ApplicationControlBar dock="true">
<mx:Form styleName="plain">
<mx:FormItem label="headerColors:" direction="horizontal">
<mx:ColorPicker id="c1" selectedColor="#FF0000" />
<mx:ColorPicker id="c2" selectedColor="#FFFFFF" />
</mx:FormItem>
</mx:Form>
</mx:ApplicationControlBar>
<mx:DateFormatter id="df"/>
</mx:Application>