Attach DateChooser to PopUpButton
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initPopupButton();" >
<mx:Script>
import mx.events.CalendarLayoutChangeEvent;
import mx.controls.DateChooser;
[Bindable]
private var myDateChooser:DateChooser = new DateChooser();
private function initPopupButton():void {
myDateChooser.selectedDate = new Date();
myDateChooser.addEventListener(CalendarLayoutChangeEvent.CHANGE, dateChangeHandler);
myPopupButton.popUp = myDateChooser;
myPopupButton.executeBindings(true);
}
private function dateChangeHandler(event:CalendarLayoutChangeEvent):void {
myPopupButton.close();
}
</mx:Script>
<mx:DateFormatter id="df" formatString="M/D/YYYY"/>
<mx:Panel title="Using the PopUpButton Control" layout="horizontal">
<mx:Label text="Select a date:"/>
<mx:PopUpButton id="myPopupButton" label="{df.format(myDateChooser.selectedDate)}" width="135"/>
</mx:Panel>
</mx:Application>
Related examples in the same category