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, // andDrawingMethods.as
is from Chapter 4 #include "MovieClip.as" #include "DrawingMethods.as" //Table.as
andForms.as
are from Chapter 11. #include "Table.as" #include "Forms.as" //TextField.as
is from Chapter 8. #include "TextField.as" function init ( ) { draw( ); // Create theXML
object and load theimages.xml
document. Be sure to set //ignoreWhite
totrue
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 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.