Parentheses
When you define a function, place any parameters inside parentheses:
function myFunction (name, age, reader){
// your code here
}
When you call a function, include any parameters passed to the function in parentheses, as
shown here:
myFunction ("Steve", 10, true);
You can also use parentheses to override the ActionScript order of precedence or to make your
ActionScript statements easier to read. (See
You also use parentheses to evaluate an expression on the left side of a dot in dot syntax. For
example, in the following statement, the parentheses cause
create a Color object:
onClipEvent(enterFrame) {
(new Color(this)).setRGB(0xffffff);
}
If you don't use parentheses, you must add a statement to evaluate the expression:
onClipEvent(enterFrame) {
myColor = new Color(this);
myColor.setRGB(0xffffff);
}
You can check for matching parentheses in your scripts; see
on page
66.
Comments
Using comments to add notes to scripts is highly recommended. Comments are useful for
keeping track of what you intended and for passing information to other developers if you work
in a collaborative environment or are providing samples. Even a simple script is easier to
understand if you make notes as you create it.
To indicate that a line or portion of a line is a comment, precede the comment with two forward
slashes (
):
//
on(release) {
// create new Date object
myDate = new Date();
currentMonth = myDate.getMonth();
// convert month number to month name
monthName = calcMonth(currentMonth);
year = myDate.getFullYear();
currentDate = myDate.getDate();
}
When Syntax coloring is enabled (see
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.
If you want to "comment out" an entire portion of your script, place it in a comment block rather
than adding
at the beginning of each line. This technique is easier and is useful when you want
//
to test only parts of a script by commenting out large chunks of it.
32
Chapter 2: ActionScript Basics
"Operator precedence and associativity" on page
new Color(this)
"Checking syntax and punctuation"
"Syntax highlighting" on page
to evaluate and
61), comments are gray by
45.)
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?
Questions and answers