Example: Writing custom classes
275
If you have to document additional information that does not fit into the documentation
comments, use implementation comments (in the format of block comments or single-line
comments, as described in
“About comments” on page 131
). Implementation comments, if
you add them, directly follow the declaration.
To document your class files:
1.
Open ClassA.as and ClassB.as in the Flash authoring tool.
2.
Modify the ClassA class file and add the new code to the top of the class file (the changes
to make appear in boldface):
/**
ClassA class
version 1.1
6/21/2005
copyright Macromedia, Inc.
*/
class com.macromedia.utils.ClassA {
private static var _className:String = "ClassA";
public function ClassA() {
trace("ClassA constructor");
}
public function doSomething():Void {
trace("ClassA - doSomething()");
}
}
The code above added a comment to the top of the class file. It’s always a good idea to add
comments to your ActionScript and Flash files so that you can add useful information
such as the author of the class, date last modified, copyright information, or any potential
issues/bugs that may be present in the file.
3.
Add a similar comment to the top of the ClassB.as ActionScript file, changing the class
name and any other information as you see fit.
4.
Save both ActionScript files before you proceed.
NO
TE
Do not include comments that do not directly relate to the class being read. For example,
do not include comments that describe the corresponding package.
NO
T
E
The following exercise is part of
“Example: Writing custom classes” on page 263
. If you
do not wish to progress through the example, you can download the class files from
www.helpexamples.com/flash/learnas/classes/.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...