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.
NOTE
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.
NOTE
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/.