Avoid using cluttered comments. An example of cluttered comments is a line of equal signs
(=) or asterisks (*) used to create a block or separation around your comments. Instead, use
white space to separate your comments from the ActionScript. If you format your
ActionScript using the Auto Format button in the Actions panel or Script window, this
removes the white space. Remember to add white space back into your code, or use single
comment lines (
) to maintain spacing; these lines are easier to remove after you format your
//
code than trying to determine where white space once was.
Before you deploy your project, remove any superfluous comments from the code, such as
"define the x and y variables" or other comments that are immediately obvious to other
developers. If you find that you have many extra comments in the ActionScript, consider
whether you need to rewrite some of the code. If you need to include many comments about
how the code works, it is usually a sign that the ActionScript is inelegant and not intuitive.
When you enable syntax coloring, comments are gray by default. Comments can be any
length without affecting the size of the exported file, and they do not need to follow rules for
ActionScript syntax or keywords.
Using comments is most important in ActionScript that is intended to teach an audience.
Add comments to your code if you are creating sample applications for the purpose of
teaching Flash or if you are writing articles or tutorials on ActionScript.
Single-line comments
You use single-line comments to add a comment to a single line in your code. You might
comment out a single line of code, or add a short description of what a piece of code
accomplishes. To indicate that a line or portion of a line is a comment, precede the comment
with two forward slashes (//), as shown in the following code:
// The following sets a local variable for age.
var myAge:Number = 26;
Single-line comments are typically used to explain a small code snippet. You can use single-
line comments for any short comments that fit on a single line. The following example
includes a single-line comment:
while (condition) {
// handle condition with statements
}
132
Syntax and Language Fundamentals
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?