About comments

Comments are a way of annotating your code with plain-English descriptions that do not get evaluated by the compiler. You can use comments within your code to describe what the code is doing or to describe which data returns to the document. Using comments can help you remember important coding decisions, and it can be helpful to anyone else who reads your code. Comments must clearly explain the intent of the code and not just translate the code. If something is not readily obvious in the code, you should add comments to it.

Using comments to add notes to scripts is highly recommended. Comments document the decisions you make in the code, answering both how and why. They make ActionScript easier to understand. For example, you might describe a work-around in comments. Therefore, you or another developer can easily find sections of code to update or fix. Or, if the issue is fixed or improved in a future version of Flash or Flash Player, you could improve the ActionScript by removing the work-around.

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.

NOTE

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.