box-o-sand/PracticingFlex/03f3-composite-component/ComponentForm.mxml

47 lines
1.6 KiB
Plaintext
Raw Normal View History

2010-02-23 03:21:27 +00:00
<?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 day:String = bday.daysCB.selectedItem.toString();
var month:String = bday.monthsCB.selectedItem.toString();
var year:String = bday.yearsCB.selectedItem.toString();
var birthdayString:String = month + ' ' + day + ', ' + year;
var birthdayDate:Date = new Date(bday.yearsCB.selectedItem, bday.monthsCB.selectedIndex,bday.daysCB.selectedIndex + 1);
var now:Date = new Date();
if (birthdayDate.toDateString() == now.toDateString()) {
Alert.show("HAPPY BIRTHDAY " + fullname.text + '!');
} else {
Alert.show("Hello " + fullname.text + '! ' + '\nYour birthday is ' + birthdayString + '.');
}
}
]]>
</mx:Script>
<mx:Form>
<mx:FormHeading label="Tell us your birthday to get a free gift!" />
<mx:FormItem label="Name:">
<mx:TextInput id="fullname" />
</mx:FormItem>
<mx:FormItem label="Your Birthday:"
direction="horizontal">
<custom:ComboBoxDateEntry id="bday" />
</mx:FormItem>
<mx:FormItem>
<mx:Button id="myButton"
label="Submit"
click="show(event)" />
</mx:FormItem>
</mx:Form>
</mx:Application>