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
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
properties" on page
Declare variables before you first use them (including loops). For example, the following
code predeclares the loop iterator variable (
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;
}
}
264
Classes
270.
XmlMenu()
"Adding methods and
) before using it in the
i
constructor and passes it
loop:
for
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?
Questions and answers