Creating an application with the DateChooser component

The following procedure explains how to add a DateChooser component to an application while authoring. In this example, the date chooser allows a user to pick a date for an airline reservation system. All dates before October 15th must be disabled. Also, a range in December must be disabled to create a holiday black-out period, and Mondays must be disabled.

To create an application with the DateChooser component:

  1. Select File > New and choose Flash File (ActionScript 2.0).
  2. Double-click the DateChooser component in the Components panel to add it to the Stage.
  3. In the Property inspector, enter the instance name flightCalendar.
  4. In the Actions panel, enter the following code on Frame 1 of the timeline to set the range of selectable dates:
    flightCalendar.selectableRange = {rangeStart:new Date(2003, 9, 15), rangeEnd:new Date(2003, 11, 31)}
    

    This code assigns a value to the selectableRange property in an ActionScript object that contains two Date objects with the variable names rangeStart and rangeEnd. This defines an upper and lower end of a range in which the user can select a date.

  5. In the Actions panel, enter the following code on Frame 1 of the timeline to set a range of holiday disabled dates:
    flightCalendar.disabledRanges = [{rangeStart: new Date(2003, 11, 15), rangeEnd: new Date(2003, 11, 26)}];
    
  6. In the Actions panel, enter the following code on Frame 1 of the timeline to disable Mondays:
    flightCalendar.disabledDays=[1];
    
  7. Select Control > Test Movie.

To create a DateChooser component instance using ActionScript:

  1. Select File > New and choose Flash File (ActionScript 2.0).
  2. Drag the DateChooser component from the Components panel to the current document's library.
  3. Select the first frame in the main Timeline, open the Actions panel, and enter the following code:
    this.createClassObject(mx.controls.DateChooser, "my_dc", 1);
    

    This script uses the method UIObject.createClassObject() to create the DateChooser instance, and then sizes and positions the grid.

  4. Select Control > Test Movie.