adding example for 03f3
This commit is contained in:
parent
d956f7dd15
commit
d117ec6066
46
03f3-composite-component/ComponentForm.mxml
Normal file
46
03f3-composite-component/ComponentForm.mxml
Normal file
@ -0,0 +1,46 @@
|
||||
<?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>
|
53
03f3-composite-component/components/ComboBoxDateEntry.mxml
Normal file
53
03f3-composite-component/components/ComboBoxDateEntry.mxml
Normal file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ADOBE SYSTEMS INCORPORATED
|
||||
// Copyright 2007 Adobe Systems Incorporated
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
|
||||
// terms of the Adobe license agreement accompanying it. If you have received this file from a
|
||||
// source other than Adobe, then your use, modification, or distribution of it requires the prior
|
||||
// written permission of Adobe.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-->
|
||||
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
|
||||
xmlns:me="components.*"
|
||||
creationComplete="init()">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
|
||||
//create bindable variables to share with components
|
||||
[Bindable]
|
||||
private var days:Array = new Array();
|
||||
|
||||
[Bindable]
|
||||
private var years:Array = new Array();
|
||||
|
||||
private function init():void{
|
||||
|
||||
//get current date
|
||||
var now:Date = new Date();
|
||||
|
||||
//populate day array
|
||||
for(var i:int=1; i<=31; i++){
|
||||
this.days.push(i);
|
||||
}
|
||||
//populate the years array up to the current year
|
||||
for(var j:int=1950; j<=now.getFullYear(); j++){
|
||||
this.years.push(j);
|
||||
}
|
||||
|
||||
//select the display values for the combo boxes based on the current date
|
||||
this.daysCB.selectedIndex = days.indexOf(now.getDate());
|
||||
this.yearsCB.selectedIndex = years.indexOf(now.getFullYear());
|
||||
}
|
||||
|
||||
|
||||
]]>
|
||||
</mx:Script>
|
||||
|
||||
<me:ComboBoxMonths id="monthsCB"/>
|
||||
<mx:ComboBox id="daysCB" dataProvider="{this.days}" width="50"/>
|
||||
<mx:ComboBox id="yearsCB" dataProvider="{this.years}" width="65"/>
|
||||
</mx:HBox>
|
48
03f3-composite-component/components/ComboBoxMonths.mxml
Normal file
48
03f3-composite-component/components/ComboBoxMonths.mxml
Normal file
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ADOBE SYSTEMS INCORPORATED
|
||||
// Copyright 2007 Adobe Systems Incorporated
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
|
||||
// terms of the Adobe license agreement accompanying it. If you have received this file from a
|
||||
// source other than Adobe, then your use, modification, or distribution of it requires the prior
|
||||
// written permission of Adobe.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
-->
|
||||
<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml" initialize="init()">
|
||||
<mx:Script>
|
||||
<![CDATA[
|
||||
import mx.formatters.DateFormatter;
|
||||
|
||||
//variable does not need to be bindable since it is not shared or changed after creation.
|
||||
private var months:Array = new Array();
|
||||
private var dateformatter:DateFormatter = new DateFormatter();
|
||||
|
||||
private function init():void{
|
||||
var i:int;
|
||||
//get the date
|
||||
var now:Date = new Date();
|
||||
//set current month
|
||||
var currentMonth:int = now.getMonth();
|
||||
//format the string to show only the month
|
||||
dateformatter.formatString = "MMMM";
|
||||
|
||||
//loop 12 times
|
||||
for (i=0; i<12; i++){
|
||||
//change the month of the date
|
||||
now.setMonth(i);
|
||||
//poplate the array with the month string
|
||||
months[i] = dateformatter.format(now);
|
||||
}
|
||||
|
||||
//set the array as the dataprovider of this combobox
|
||||
this.dataProvider = months;
|
||||
//select current month
|
||||
this.selectedIndex = currentMonth;
|
||||
}
|
||||
]]>
|
||||
</mx:Script>
|
||||
</mx:ComboBox>
|
||||
|
@ -163,6 +163,10 @@
|
||||
$(MXMLC) 03f2-code-behind/CodeExample.mxml -warnings -l+=03f2-code-behind -output 03f2-code-behind/CodeExample.swf
|
||||
|
||||
|
||||
03f3-composite-component/ComponentForm.swf: 03f3-composite-component/components/ComboBoxDateEntry.mxml 03f3-composite-component/ComponentForm.mxml 03f3-composite-component/components/ComboBoxMonths.mxml
|
||||
$(MXMLC) 03f3-composite-component/ComponentForm.mxml -warnings -l+=03f3-composite-component -output 03f3-composite-component/ComponentForm.swf
|
||||
|
||||
|
||||
custom-03d1-datagrid/Snarf.swf: custom-03d1-datagrid/Snarf.mxml custom-03d1-datagrid/CustomApp.as
|
||||
$(MXMLC) custom-03d1-datagrid/Snarf.mxml -warnings -l+=custom-03d1-datagrid -output custom-03d1-datagrid/Snarf.swf
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user