You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB

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;
}
}
}