Flash CS3 Documentation |
|||
| Learning ActionScript 2.0 in Adobe Flash > Classes > Example: Writing custom classes > Documenting the classes | |||
Using comments in your classes and interfaces is an important part of documenting them for other users. For example, you might want to distribute your class files into the Flash community, or you might be working with a team of designers or developers who will use your class files in their work or as part of a project you're working on. Documentation helps other users understand the purpose and origins of the class.
There are two kinds of comments in a typical class or interface file: documentation comments and implementation comments. You use documentation comments to describe the code's specifications, but not the implementation. You use implementation comments to comment out code or to comment on the implementation of particular sections of code. The two kinds of comments use slightly different delimiters. Documentation comments are delimited with /** and */, and implementation comments are delimited with /* and */.
|
NOTE |
|
Documentation comments are not a language construct in ActionScript 2.0. However, they are a common way of structuring comments in a class file that you can use in your AS files. |
Use documentation comments to describe interfaces, classes, methods, and constructors. Include one documentation comment per class, interface, or member, and place it directly before the declaration.
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). Implementation comments, if you add them, directly follow the declaration.
|
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. If you do not wish to progress through the example, you can download the class files from www.helpexamples.com/flash/learnas/classes/. |
/**ClassA classversion 1.16/21/2005copyright Adobe Systems Incorporated*/class com.adobe.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.
You might also add the block, single-line, or trailing comments within the class's code. For information on writing good comments within your code, see Writing good comments. For general information about comments, see Single-line comments, Multiline comments, and Trailing comments.
To learn how to use these custom class files in a SWF file, see Example: Using custom class files in Flash.
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00000794.html