
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Comments
|
395
on (release) { // No semicolon here
trace("Click"); // Semicolon here
} // No semicolon here
However, the semicolon is mandatory following a function literal:
function (param1, param2, ... paramn) { statements };
The special #include directive, and the #initclip and #endinitclip pragmas should
not be followed by a semicolon and will cause an error if used with one. For correct
usage, see the Language Reference.
Comments
So-called comments are text that is ignored by the interpreter but entered by the pro-
grammer specifically for the benefit of humans reading the code. Comments should
be used liberally to explain what the code does, provide version control information,
or describe other relevant information, such as how a data structure is being used or
why certain programming choices were made. Comments should describe your code
at the conceptual level, not merely mirror the syntax of the code itself. For example,
the following comment is useless:
// Set x equal to 5
var x = 5;
whereas the following comment tells us why we’re setting x to 5, which helps us fol-
low the flow of the code:
// Initialize our player's x position
var x = 5;
Note that you can go a long way toward making your code “self-commenting” by
using descriptive variable names and handler names. Consider which ...