Putting the Application Together

The final step in creating a working scheduler application is to create the main code routine on the main timeline of the Flash document. Essentially, the main routine is responsible for three things:

  • Creating an instance of Macromedia’s Calendar component (the FCalendarSymbol must be available in the Library)

  • Creating an instance of the Schedule component

  • Creating functionality that opens a schedule item that corresponds to a calendar date when the calendar date is double-clicked

All you need to do to complete the scheduler application is add the following code to the first frame of the default layer of the Flash document’s main timeline:

// Include DrawingMethods.as from Chapter 4.
#include "DrawingMethods.as"
// Include MovieClip.as from Chapter 7 and TextField.as from Chapter 8.
#include "MovieClip.as"
#include "TextField.as"
// Include Date.as from Chapter 10 and Tables.as from Chapter 11.
#include "Date.as"
#include "Table.as"

function init(  ) {

  // Create an instance of the Calendar component.
  _root.attachMovie("FCalendarSymbol", "cal", _root.getNewDepth(  ));
  cal.setChangeHandler("onSelectDate");
  cal.setSize(Stage.width, Stage.height);

  // Create a Schedule component instance.
  _root.attachMovie("ScheduleSymbol", "scheduler", _root.getNewDepth(  ));
  scheduler.setOnClose("onScheduleClose", _root);
}

// The onSelectDate(  ) function is the callback function for the Calendar component. function onSelectDate(cmpt) { // Get the time, in milliseconds, since ...

Get Actionscript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.