MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 271

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

A class's members consist of properties (variable declarations) and methods (function
definitions). You must declare and define all properties and methods inside the class body (the
curly braces [
]); otherwise, an error occurs during compilation. For information on
{}
members, see
"About public, private, and static methods and properties (members)"
on page
247.
To add methods to the ClassA and ClassB classes:
1.
Open ClassA.as and ClassB.as in the Flash authoring tool.
2.
Modify the ClassA class file so it matches the following code (the changes to make appear
in boldface):
class com.macromedia.utils.ClassA {
static var _className:String;
function ClassA() {
trace("ClassA constructor");
}
function doSomething():Void {
trace("ClassA - doSomething()");
}
}
The block of code in boldface creates a new method in the class, which traces a string to
the Output panel.
3.
In ClassA.as, select Tools > Check Syntax to check the syntax of your ActionScript file.
If any errors are reported in the Output panel, compare the ActionScript in your script to
the complete code written in the previous step. If you cannot fix the code errors, copy and
paste the complete code into the Script window before you proceed.
4.
Check the syntax of ClassB.as as you did in ClassA.as.
If any errors appear in the Output panel, copy and paste the complete code into the Script
window before you proceed:
class com.macromedia.utils.ClassB {
static var _className:String;
function ClassB() {
trace("ClassB constructor");
}
function doSomething():Void {
trace("ClassB - doSomething()");
}
}
5.
Save both ActionScript files before you proceed.
Example: Writing custom classes
271

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

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

This manual is also suitable for:

Flash 8

Table of Contents