Main Page | Packages | Class Tree | Index | Help

com.bjc.controls

class Calendar

MovieClip
  |
  +--com.bjc.core.BJCComponent
        |
        +--com.bjc.controls.Calendar


class Calendar
extends BJCComponent

A highly customizable calendar component.

Events:

click - Fired whenever the user clicks the mouse on one of the dates in the calender, changing the currently selected date.
focus - Fired whenever the component receives focus.
killFocus - Fired whenever the component loses focus.
tabFocus - Fired whenever the component receives focus by pressing the TAB key.


Author:
Flashloaded - www.flashloaded.com


Field Summary

public
addEventListener: Function
See the EventDispatcher Class in Flash Help

public
clickHandler: Function
Can be used to assign a direct event handler to the component instance.

public
focusHandler: Function
Can be used to assign a direct event handler to the component instance.

public
killFocusHandler: Function
Can be used to assign a direct event handler to the component instance.

public
removeEventListener: Function
See the EventDispatcher Class in Flash Help

public
tabFocusHandler: Function
Can be used to assign a direct event handler to the component instance.

Fields inherited from class com.bjc.core.BJCComponent

version

Property Summary

public
dataProvider: Array (write)
An array used to hold the data used by the calendar. Each element of the array holds an object, which contains two properties. The date property holds an instance of the Flash Date class. The data property can hold any value.

public
dataProvider: Array (read)
Gets the array used to hold the data used by the calendar.

public
dateDisabledColor: Number (write)
Sets the color of date text when the calendar is disabled, as described in the Label component.

public
dateDisabledColor: Number (read)
Gets the color of date text when the calendar is disabled, as described in the Label component.

public
dateEmbedFont: Boolean (write)
Sets whether the font for the date text will be embedded, as described in the Label component.

public
dateEmbedFont: Boolean (read)
Gets whether the font for the date text will be embedded, as described in the Label component.

public
dateFontColor: Number (write)
Sets the text color of dates, as described in the Label component.

public
dateFontColor: Number (read)
Gets the text color of dates, as described in the Label component.

public
dateFontFace: String (write)
Sets the font used for the dates, as described in the Label component.

public
dateFontFace: String (read)
Gets the font used for the dates, as described in the Label component.

public
dateFontSize: Number (write)
Sets the size of the font used for the dates, as described in the Label component.

public
dateFontSize: Number (read)
Gets the size of the font used for the dates, as described in the Label component.

public
dayNames: Array (write)
An array of 7 strings used to display the names of the weekdays in the calendar. The first weekday in the clendar is Sunday.

public
dayNames: Array (read)
Gets an array of 7 strings used to display the names of the weekdays in the calendar.

public
headerDisabledColor: Number (write)
Sets the color of header text when the calendar is disabled, as described in the Label component.

public
headerDisabledColor: Number (read)
Gets the color of header text when the calendar is disabled, as described in the Label component.

public
headerEmbedFont: Boolean (write)
Sets whether the font for the header text will be embedded, as described in the Label component.

public
headerEmbedFont: Boolean (read)
Gets whether the font for the header text will be embedded, as described in the Label component.

public
headerFontColor: Number (write)
Sets the text color of the header, as described in the Label component.

public
headerFontColor: Number (read)
Gets the text color of the header, as described in the Label component.

public
headerFontFace: String (write)
Sets the font used for the header, as described in the Label component.

public
headerFontFace: String (read)
Gets the font used for the header, as described in the Label component.

public
headerFontSize: Number (write)
Sets the size of the font used for the header, as described in the Label component.

public
headerFontSize: Number (read)
Gets the size of the font used for the header, as described in the Label component.

public
markedColor: Number (write)
Sets the background color of the special dates added to the calender.

public
markedColor: Number (read)
Gets the background color of the special dates added to the calender.

public
monthNames: Array (write)
An array of twelve strings used to display the names of the months in the calendar.

public
monthNames: Array (read)
Gets an array of twelve strings used to display the names of the months in the calendar.

public
rolloverColor: Number (write)
Sets the background color of the dates when the mouse moves over them.

public
rolloverColor: Number (read)
Gets the background color of the dates when the mouse moves over them.

public
selectedColor: Number (write)
Sets the background color of the dates when selected.

public
selectedColor: Number (read)
Gets the background color of the dates when selected.

public
selectedItem: Object (read)
Returns the object associated with the selected date, in the form described in the dataProvider property description.

public
selectedItem: Date (write)
Returns the object associated with the selected date, in the form described in the dataProvider property description.

public
todayColor: Number (write)
Sets the background color of the current date.

public
todayColor: Number (read)
Gets the background color of the current date.

public
yearFormat: Number (write)
Specifies how the year will be displayed in the calendar. A value of 4 will display in the format 2004, 3 will display '04, 2 will display 04.

public
yearFormat: Number (read)
Gets how the year is displayed in the calendar.

Properties inherited from class com.bjc.core.BJCComponent

disabledAlpha, enabled, focusTime, height, keyEnabled, style, width

Constructor

public
Calendar ( Void)


Method Summary

public
addItem ( ): Void
Adds a item to the calendar, consisting of a date and a data object. The date can be in the form of a single Date object, or passed as three separate parameters, year, month and date. In either case, the next parameter will be the data object. The item added will be put at the end of the array being used as a dataProvider.

public static
create ( target: MovieClip, id: String, depth: Number, initObj: Object ): Calendar
Static method used to create an instance of a Calendar on stage at run time.

public
removeAll ( Void ): Void
Removes all data that has been previously added to the calender, clearing any external array being used as a dataProvider.

public
removeItem ( year: Number, month: Number, date: Number ): Void
Removes the item stored at the specified date.

public
setDate ( ): Void
Sets the current date of the calendar and displays that month. There are two ways to call this function. First, by passing it a date object of the date you want to change to. The other way is to pass in the year, month and date of the date you want to change to.

Methods inherited from class com.bjc.core.BJCComponent

draw, invalidate, move, remove, setSize



Field Documentation

addEventListener

public var addEventListener: Function
See the EventDispatcher Class in Flash Help

clickHandler

public var clickHandler: Function
Can be used to assign a direct event handler to the component instance.

Usage:
myCalendar.clickHandler = function(){
trace("I was clicked.");
}

focusHandler

public var focusHandler: Function
Can be used to assign a direct event handler to the component instance.

Usage:
myCalendar.focusHandler = function(){
trace("Set focus.");
}

killFocusHandler

public var killFocusHandler: Function
Can be used to assign a direct event handler to the component instance.

Usage:
myCalendar.killFocusHandler = function(){
trace("Kill focus.");
}

removeEventListener

public var removeEventListener: Function
See the EventDispatcher Class in Flash Help

tabFocusHandler

public var tabFocusHandler: Function
Can be used to assign a direct event handler to the component instance.

Usage:
myCalendar.tabFocusHandler = function(){
trace("Tab focus.");
}


Property Documentation

dataProvider

public dataProvider: Array (write)
An array used to hold the data used by the calendar. Each element of the array holds an object, which contains two properties. The date property holds an instance of the Flash Date class. The data property can hold any value.

Example:
var myDates:Array = [{date:new Date(2004, 11, 25), data:"Christmas"}];
myCalendar.dataProvider = myDates;

dataProvider

public dataProvider: Array (read)
Gets the array used to hold the data used by the calendar.

Example:
myVar = myCalendar.dataProvider;

dateDisabledColor

public dateDisabledColor: Number (write)
Sets the color of date text when the calendar is disabled, as described in the Label component.

Example:
myCalendar.dateDisabledColor = 0xcccccc;

dateDisabledColor

public dateDisabledColor: Number (read)
Gets the color of date text when the calendar is disabled, as described in the Label component.

Example:
myVar = myCalendar.dateDisabledColor;

dateEmbedFont

public dateEmbedFont: Boolean (write)
Sets whether the font for the date text will be embedded, as described in the Label component.

Example:
myCalendar.dateEmbedFont = true;

dateEmbedFont

public dateEmbedFont: Boolean (read)
Gets whether the font for the date text will be embedded, as described in the Label component.

Example:
myVar = myCalendar.dateEmbedFont;

dateFontColor

public dateFontColor: Number (write)
Sets the text color of dates, as described in the Label component.

Example:
myCalendar.dateFontColor = 0x333333;

dateFontColor

public dateFontColor: Number (read)
Gets the text color of dates, as described in the Label component.

Example:
myVar = myCalendar.dateFontColor;

dateFontFace

public dateFontFace: String (write)
Sets the font used for the dates, as described in the Label component.

Example:
myCalendar.dateFontFace = "Arial";

dateFontFace

public dateFontFace: String (read)
Gets the font used for the dates, as described in the Label component.

Example:
myVar = myCalendar.dateFontFace;

dateFontSize

public dateFontSize: Number (write)
Sets the size of the font used for the dates, as described in the Label component.

Example:
myCalendar.dateFontSize = 20;

dateFontSize

public dateFontSize: Number (read)
Gets the size of the font used for the dates, as described in the Label component.

Example:
myVar = myCalendar.dateFontSize;

dayNames

public dayNames: Array (write)
An array of 7 strings used to display the names of the weekdays in the calendar. The first weekday in the clendar is Sunday.

Example:
myCalendar.dayNames = ["S", "M", "T", "W", "T", "F", "S"];
myCalendar.dayNames[0] = "S";

dayNames

public dayNames: Array (read)
Gets an array of 7 strings used to display the names of the weekdays in the calendar.

Example:
myVar = myCalendar.dayNames;

headerDisabledColor

public headerDisabledColor: Number (write)
Sets the color of header text when the calendar is disabled, as described in the Label component.

Example:
myCalendar.headerDisabledColor = 0xcccccc;

headerDisabledColor

public headerDisabledColor: Number (read)
Gets the color of header text when the calendar is disabled, as described in the Label component.

Example:
myVar = myCalendar.headerDisabledColor;

headerEmbedFont

public headerEmbedFont: Boolean (write)
Sets whether the font for the header text will be embedded, as described in the Label component.

Example:
myCalendar.headerEmbedFont = true;

headerEmbedFont

public headerEmbedFont: Boolean (read)
Gets whether the font for the header text will be embedded, as described in the Label component.

Example:
myVar = myCalendar.headerEmbedFont;

headerFontColor

public headerFontColor: Number (write)
Sets the text color of the header, as described in the Label component.

Example:
myCalendar.headerFontColor = 0xff00cc;

headerFontColor

public headerFontColor: Number (read)
Gets the text color of the header, as described in the Label component.

Example:
myVar = myCalendar.headerFontColor;

headerFontFace

public headerFontFace: String (write)
Sets the font used for the header, as described in the Label component.

Example:
myCalendar.headerFontFace = "Arial";

headerFontFace

public headerFontFace: String (read)
Gets the font used for the header, as described in the Label component.

Example:
myVar = myCalendar.headerFontFace;

headerFontSize

public headerFontSize: Number (write)
Sets the size of the font used for the header, as described in the Label component.

Example:
myCalendar.headerFontSize = 20;

headerFontSize

public headerFontSize: Number (read)
Gets the size of the font used for the header, as described in the Label component.

Example:
myVar = myCalendar.headerFontSize;

markedColor

public markedColor: Number (write)
Sets the background color of the special dates added to the calender.

Example:
myCalendar.markedColor = 0xff00cc;

markedColor

public markedColor: Number (read)
Gets the background color of the special dates added to the calender.

Example:
myVar = myCalendar.markedColor;

monthNames

public monthNames: Array (write)
An array of twelve strings used to display the names of the months in the calendar.

Example:
myCalendar.monthNames = ["Jan", "Feb", "Mar" ... "Dec"];
myCalendar.monthNames[1] = "February!!!";

monthNames

public monthNames: Array (read)
Gets an array of twelve strings used to display the names of the months in the calendar.

Example:
myVar = myCalendar.monthNames;

rolloverColor

public rolloverColor: Number (write)
Sets the background color of the dates when the mouse moves over them.

Example:
myCalendar.rolloverColor = 0xffcc00;

rolloverColor

public rolloverColor: Number (read)
Gets the background color of the dates when the mouse moves over them.

Example:
myCalendar.rolloverColor = 0xffcc00;

selectedColor

public selectedColor: Number (write)
Sets the background color of the dates when selected.

Example:
myCalendar.selectedColor = 0xffccff;

selectedColor

public selectedColor: Number (read)
Gets the background color of the dates when selected.

Example:
myVar = myCalendar.selectedColor;

selectedItem

public selectedItem: Object (read)
Returns the object associated with the selected date, in the form described in the dataProvider property description.

Example:
trace(myCalendar.selectedItem.date);
trace(myCalendar.selectedItem.data);

selectedItem

public selectedItem: Date (write)
Returns the object associated with the selected date, in the form described in the dataProvider property description.

Example:
trace(myCalendar.selectedItem.date);
trace(myCalendar.selectedItem.data);

todayColor

public todayColor: Number (write)
Sets the background color of the current date.

Example:
myCalendar.todayColor = 0xffccff;

todayColor

public todayColor: Number (read)
Gets the background color of the current date.

Example:
myVar = myCalendar.todayColor;

yearFormat

public yearFormat: Number (write)
Specifies how the year will be displayed in the calendar. A value of 4 will display in the format 2004, 3 will display '04, 2 will display 04.

Example:
myCalendar.yearFormat = 3;

yearFormat

public yearFormat: Number (read)
Gets how the year is displayed in the calendar.

Example:
myVar = myCalendar.yearFormat;


Constructor Documentation

Calendar

public function Calendar(Void)

Method Documentation

addItem

public function addItem(): Void
Adds a item to the calendar, consisting of a date and a data object. The date can be in the form of a single Date object, or passed as three separate parameters, year, month and date. In either case, the next parameter will be the data object. The item added will be put at the end of the array being used as a dataProvider.

Returns:
nothing

Example:
First usage:
var today:Date = new Date();
myCalendar.addItem(today, "My Birthday");
Second usage:
myCalendar.addItem(2004, 11, 25, "Christmas");
Using an object:
myCalendar.addItem(new Date(), {temperature:73, humidity:50});

create

public static function create(target: MovieClip,
 id: String,
 depth: Number,
 initObj: Object): Calendar
Static method used to create an instance of a Calendar on stage at run time.

Parameters:
target
the movie clip to which the calendar will be attached.
id
the instance name given to the new calendar attached.
depth
the depth at which to attach the new calendar.
initObj
(optional) an object containing any properties you want to assign to the component when it is created
Returns:
a reference to the new calendar attached.

Example:
import com.bjc.controls.Calendar;
var newCalendar:Calendar = Calendar.create(_root, "myCalendar", 0);

removeAll

public function removeAll(Void): Void
Removes all data that has been previously added to the calender, clearing any external array being used as a dataProvider.

Returns:
nothing

Example:
myCalendar.removeAll();

removeItem

public function removeItem(year: Number,
 month: Number,
 date: Number): Void
Removes the item stored at the specified date.

Parameters:
year
a four digit number representing the year, e.g. 2004.
month
a zero index number representing the month, i.e. 0 = January, 11 = December.
date
a number representing the day of the month (1 - 31)
Returns:
nothing

Example:
myCalendar.removeItem(2004, 12, 25);

setDate

public function setDate(): Void
Sets the current date of the calendar and displays that month. There are two ways to call this function. First, by passing it a date object of the date you want to change to. The other way is to pass in the year, month and date of the date you want to change to.

Returns:
nothing

Example:
// usage 1:
myDate = new Date(cal1.selectedItem.year, cal1.selectedItem.month, cal1.selectedItem.date);
cal2.setDate(myDate);
 
// usage 2:
cal1.setDate(2005, 11, 25);


The documentation was generated from the following file:


Copyright Flashloaded - www.flashloaded.com