Using XML

By filling in a value in the XML field in the component's properties panel, you instruct the component to load the calendar data from an external XML file. The XML file can be created using any text editor (e.g. Notepad). Here is an example as to how the component's XML file might look:

<?xml version="1.0" encoding="utf-8"?>
<events init="0" from="-365" to="0">
  <day date="0" value="selected">Today!</day>
  <day date="1/6/2004" state="wine" />
  <range from="2/5/2004" to="4/5/2004" state="rose" value="selected">Holidays!</range>
  <range from="5/1/2004" to="11/1/2004" value="disabled" />
  <recurrent type="month" pattern="0,0,0,0,0,0,0,0,0,0,0,1" monthday="24" state="wine"/>
  <recurrent type="month" pattern="0,1" monthday="1" value="selected" state="rose">1st of 2nd month</recurrent>
  <recurrent type="month" pattern="1" week="-1" day="1" state="wine">last week!</recurrent>
  <recurrent type="week" pattern="1" day="0" value="selected"/>
</events>

The first line of the file is a typical XML declaration. It declares the version of the XML file and the encoding that will be used.

events Tag

All of the calendar events have to be specified inside an events tag which has the following properties:

init - defines the initial date.
rinit - defines the recurrent
event initial date. If this value is not specified, the init date will be used for the recurrent initial date instead.
from - defines the first selectable date in the calendar
to - defines the last selectable date in the calendar

Please see properties description for more information.

The date format is dd/mm/yyyy however you can also enter a positive or negative number, as well as zero. A value of "0" will be the equivalent of writing the current date; -1 is yesterday's date; 1 is tomorrow's date etc. This is useful when you need to instruct the component to always select the current date, for example:

<events init="0" from="-365" to="0">
In this example, the component will initialize with today's date and it will allow the user to select the last 365 days.

The same thing if, for example, the current date is 1st of October 2004, can be written as:
<events init="
1/10/2004" from="1/10/2003" to="1/10/2004">

In this example, the component will initialize with today's date and it will allow the user to select the last 365 days. The recurrent event inital date has also been set to 1/1/2004:
<events init="0" rinit="1/1/2004" from="1/10/2003" to="1/10/2004">


There are 3 tags that can be defined inside the events tag: day, range and recurrent.

All of these tags can have 2 common properties:

argument name description possible values
state The state of the component.
The default state does not have to be defined. You will need to use this though after creating your own states (please see the Skinning Tutorial).
whatever you choose to name the states
value The value of the component.
Use it if you want a specific date to be either pre-selected or disabled.

"selected" or "disabled"

Also, each of 3 tags can have a text value that is used as the content property in the component's ActionScript. For example:

<range from="2/5/2004" to="4/5/2004" state="rose" value="selected">Holidays!</range>

will have value of the content property "Holidays!"

day Tag

Use the day tag to define an event that will occur on a specific day:

The day tag has one specific property:

argument name description possible values
date the date of the event
date in format dd/mm/yyyy or any numeric value*
* date property can be defined using 0 for the current date etc, as explained above

Example:

<day date="0" value="selected">Today!</day>

or using the date format:

<day date="1/6/2004" value="selected">Today!</day>

In the case that the current date is 1st of June 2004, both examples above will do the same thing.

range TAG

Use the range tag to define the range of the events:

The range tag properties are:

argument name description possible values
from the date of the first event in the range
date in format dd/mm/yyyy or any numeric value*
to the date of the last event in the range

date in format dd/mm/yyyy or any numeric value*

* Both from and to properties can be defined using 0 for current date etc, as explained above

Example:

<range from="2/5/2004" to="4/5/2004" value="disabled" />
disables days from the 2nd to the 5th of May 2004

recurrent Tag

Use the recurrent tag to define a recurring event:

The recurrent tag properties are:

argument name description possible values
type defines if the event will repeat periodically every year, month, week or day.
"year", "month", "week" or "day"
pattern the repeating pattern
For example: "1" means that the event will repeat each period type. This value is based on the "reinit" date set in the events tag. If the reinit dats is set at 1/1/2004 and the type is "year", "0,1" means that the event will happen in 2005, 2007, 2009 etc.

comma separated string of 0's and 1's

It is also possible to add a value like "0x4,1", which is the same as writing "0,0,0,0,1", which means that the event that will happen every fifth event type. See the examples below for more information.

month

valid only when type is "year".
Defines the month in which the event will occur.

1-12
yearweek valid only when type is "year".
Defines the week of the year in which the event will occur.
1-53
week valid only when type is "year" or "month"
Defines the week of the month in which the event will happen. Negative values are also possible. For example -1 will be last week of the month (when the type is month).
1-5
yearday valid only when type is "year"
Defines the day of the year in which event will occur.
1-366
monthday valid only when type is "year" or "month"
Defines the day of the month in which the event will occur.
1-31
day valid only when type is "year" or "month" or "week"
Defines the day of the week in which the event will occur.
0-6
0 is Sunday, 1 is Monday... 6 is Saturday


Examples of recurrent events XML definitions:

<recurrent type="year" pattern="1" month="8" monthday="24" state="holiday" value="selected"/>
event will happen every year on the 24th of August (24th of August will have state holiday and it will be selected)

<recurrent type="year" pattern="0x3,1" yearweek="2" day="6" value="disabled"/>
every Saturday(value 0 for day is Sunday, so value 6 for day will be Saturday) of the second week of every fourth year will be disabled

<recurrent type="month" pattern="0,1" week="2" day="1" value="disabled"/>
event will happen on Monday every second week of the every second month starting from next month of the rinit date

<recurrent type="week" pattern="1" day="0" state="holiday" value="selected">Sunday!</recurrent>
event will happen every Sunday

<recurrent type="day" pattern="0x4,1" state="holiday"/>
event will happen every 5 days from the rinit Date

 

Displaying content using HTML tags

You can display the content text on multlple lines, include hyperlinks and format the text by using HTML content. In order to include HTML tags in the XML file you should wrap the conent in CDATA tags.

For example:

<recurrent type="year" pattern="1" month="1" monthday="1" state="holiday" value="selected">
<![CDATA[ Happy<br> <b>New Year</b> ]]>
</recurrent>

When you assign the content to a dynamic textfield you should also use the htmlText property instead of the text property.