adding example for 03f4
This commit is contained in:
parent
d117ec6066
commit
f7b841e21e
52
03f4-multiple-composite-components/Main.mxml
Normal file
52
03f4-multiple-composite-components/Main.mxml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?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>
|
@ -0,0 +1,82 @@
|
|||||||
|
<?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:custom="components.*"
|
||||||
|
creationComplete="init()">
|
||||||
|
<mx:Script>
|
||||||
|
<![CDATA[
|
||||||
|
import mx.events.ListEvent;
|
||||||
|
//create bindable variables to share with components
|
||||||
|
[Bindable]
|
||||||
|
private var days:Array;
|
||||||
|
|
||||||
|
[Bindable]
|
||||||
|
private var years:Array = new Array();
|
||||||
|
|
||||||
|
private function init():void{
|
||||||
|
this.monthsCB.addEventListener(ListEvent.CHANGE,monthsHandler);
|
||||||
|
//get current date
|
||||||
|
var now:Date = new Date();
|
||||||
|
|
||||||
|
//populate days and year
|
||||||
|
setDays(now.getMonth());
|
||||||
|
setYears(now.getFullYear());
|
||||||
|
|
||||||
|
//select the display values for the combo boxes based on the current date
|
||||||
|
this.daysCB.selectedIndex = 0;
|
||||||
|
this.yearsCB.selectedIndex = years.indexOf(now.getFullYear());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function monthsHandler(event:ListEvent):void{
|
||||||
|
setDays(event.currentTarget.selectedIndex);
|
||||||
|
this.daysCB.selectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setDays(month:int):void{
|
||||||
|
this.days = new Array();
|
||||||
|
var i:int;
|
||||||
|
|
||||||
|
if (month == 0 || month == 2 || month == 4 || month == 6 || month == 7 || month == 9 || month == 11){
|
||||||
|
for(i=1; i<=31; i++)
|
||||||
|
this.days.push(i);
|
||||||
|
|
||||||
|
}else if (month == 3 || month == 5 || month == 8 || month == 10){
|
||||||
|
for(i=1; i<=30; i++)
|
||||||
|
this.days.push(i);
|
||||||
|
|
||||||
|
}else if (month == 1){
|
||||||
|
if (yearsCB.selectedIndex % 4 == 0){
|
||||||
|
for(i=1; i<=29; i++)
|
||||||
|
this.days.push(i);
|
||||||
|
}else{
|
||||||
|
for(i=1; i<=28; i++)
|
||||||
|
this.days.push(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setYears(year:int):void{
|
||||||
|
var j:int;
|
||||||
|
for(j=1950; j<=year; j++){
|
||||||
|
this.years.push(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</mx:Script>
|
||||||
|
|
||||||
|
<custom:ComboBoxMonths id="monthsCB"/>
|
||||||
|
<mx:ComboBox id="daysCB" dataProvider="{this.days}" width="50"/>
|
||||||
|
<mx:ComboBox id="yearsCB" dataProvider="{this.years}" width="70"/>
|
||||||
|
</mx:HBox>
|
@ -0,0 +1,53 @@
|
|||||||
|
package components
|
||||||
|
{
|
||||||
|
import mx.controls.ComboBox;
|
||||||
|
import mx.formatters.DateFormatter;
|
||||||
|
/*
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
*/
|
||||||
|
public class ComboBoxMonths extends ComboBox
|
||||||
|
{
|
||||||
|
private var months:Array = new Array();
|
||||||
|
private var dateformatter:DateFormatter = new DateFormatter();
|
||||||
|
|
||||||
|
public function ComboBoxMonths()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
init();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -167,6 +167,10 @@
|
|||||||
$(MXMLC) 03f3-composite-component/ComponentForm.mxml -warnings -l+=03f3-composite-component -output 03f3-composite-component/ComponentForm.swf
|
$(MXMLC) 03f3-composite-component/ComponentForm.mxml -warnings -l+=03f3-composite-component -output 03f3-composite-component/ComponentForm.swf
|
||||||
|
|
||||||
|
|
||||||
|
03f4-multiple-composite-components/Main.swf: 03f4-multiple-composite-components/Main.mxml 03f4-multiple-composite-components/components/ComboBoxDateEntry.mxml 03f4-multiple-composite-components/components/ComboBoxMonths.as
|
||||||
|
$(MXMLC) 03f4-multiple-composite-components/Main.mxml -warnings -l+=03f4-multiple-composite-components -output 03f4-multiple-composite-components/Main.swf
|
||||||
|
|
||||||
|
|
||||||
custom-03d1-datagrid/Snarf.swf: custom-03d1-datagrid/Snarf.mxml custom-03d1-datagrid/CustomApp.as
|
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
|
$(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