Putting Together the Application

Once you have created all the components, you can breathe a sigh of relief knowing that you have completed all the difficult work. All that remains is to put the components together so they work in conjunction with one another to produce a complete, working application.

The main routine of the application is responsible for the following:

  • Adding all the necessary components to the movie at runtime

  • Loading the XML data

  • Listening for keypresses

To complete the main routine of the image viewer application, add the following code to the first frame of the default layer of the main timeline:

// Include the necessary libraries in the document. MovieClip.as is from Chapter 7,
// and DrawingMethods.as is from Chapter 4
#include "MovieClip.as"
#include "DrawingMethods.as"
// Table.as and Forms.as are from Chapter 11.
#include "Table.as"
#include "Forms.as"
// TextField.as is from Chapter 8.
#include "TextField.as"

function init (  ) {
  draw(  );

  // Create the XML object and load the images.xml document. Be sure to set
  // ignoreWhite to true so that the extra whitespace nodes are eliminated. imagesXML = new XML( ); imagesXML.ignoreWhite = true; imagesXML.load("images.xml"); imagesXML.onLoad = XMLOnLoad; } function draw ( ) { // Create the Menu component and the Preview Pane component. _root.attachMovie("MenuSymbol", "imagesMenu", _root.getNewDepth( )); _root.attachMovie("PreviewPaneSymbol", "previewPn", _root.getNewDepth( )); imagesMenu.setPreviewPane(previewPn); ...

Get Actionscript Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.