EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 264

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
264 Classes
A sample file on your hard disk demonstrates how to create a dynamic menu with XML data
and a custom class file. The sample calls the ActionScript
XmlMenu() constructor and passes it
two parameters: the path to the XML menu file and a reference to the current timeline. The
rest of the functionality resides in a custom class file, XmlMenu.as.
You can find the sample source file, xmlmenu.fla, in the Samples folder on your hard disk.
On Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\XML_Menu.
On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/XML_Menu.
About general guidelines for creating a class
The following points are guidelines to follow when you write custom class files. They help
you write correct and well-formed classes. You practice these guidelines in upcoming
examples.
In general, place only one declaration per line, and do not place either the same or
different types of declarations on a single line. Format your declarations as the following
example shows:
private var SKU:Number; // product SKU (identifying) number
private var quantity:Number; // quantity of product
Initialize local variables when you declare them, unless that initial value is determined by a
calculation. For information on initializing variables, see Adding methods and
properties” on page 270.
Declare variables before you first use them (including loops). For example, the following
code predeclares the loop iterator variable (
i) before using it in the for loop:
var my_array:Array = new Array("one", "two", "three");
var i:Number;
for (i = 0 ; i < my_array.length; i++) {
trace(i + " = " + my_array[i]);
}
Avoid using local declarations that hide higher-level declarations. For example, do not
declare a variable twice, as the following example shows:
// bad code
var counter:Number = 0;
function myMethod() {
var counter:Number;
for (counter = 0; counter <= 4; counter++) {
// statements;
}
}

Table of Contents

Related product manuals