O'Reilly logo

Actionscript Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required