<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    backgroundColor="#FFFFFF"
    backgroundAlpha="0"
    xmlns:custom="components.*">

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;

            private function show(event:Event):void {
                var sday:Number = sdate.daysCB.selectedIndex + 1;
                var smonth:Number = sdate.monthsCB.selectedIndex;
                var syear:Object = sdate.yearsCB.selectedItem.toString();

                var eday:Number = edate.daysCB.selectedIndex + 1;
                var emonth:Number = edate.monthsCB.selectedIndex;
                var eyear:Object = edate.yearsCB.selectedItem.toString();

                var startDate:Date = new Date(syear,smonth,sday);
                var endDate:Date = new Date(eyear,emonth,eday);

                if (endDate < startDate){
                    Alert.show("Please enter a end date greater than the start date.");
                }else{
                    Alert.show("The record search is between " +
                               dateFormat.format(startDate)  + ' and ' +
                               dateFormat.format(endDate));
                }
            }
        ]]>
    </mx:Script>

    <mx:DateFormatter id="dateFormat"
        formatString="MM/DD/YYYY" />

    <mx:Form>
        <mx:FormHeading label="Record Search" />
        <mx:FormItem label="Start Date">
            <custom:ComboBoxDateEntry id="sdate" />
        </mx:FormItem>
        <mx:FormItem label="End Date">
            <custom:ComboBoxDateEntry id="edate" />
        </mx:FormItem>
        <mx:FormItem>
            <mx:Button id="myButton"
                label="Search"
                click="show(event)" />
        </mx:FormItem>
    </mx:Form>

</mx:Application>
