|
|
|
|
| Tutorial |
You can also use parentheses to override the ActionScript order of precedence or to make your
ActionScript statements easier to read.
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 new Color(this) to evaluate and
create a new Color object:<>
onClipEvent(enterFrame) {
(new Color(this)).setRGB(0xffffff);
}
If you didn’t use parentheses, you would need to add a statement to evaluate the expression:
onClipEvent(enterFrame) {
myColor = new Color(this);
myColor.setRGB(0xffffff);
}
Uppercase and lowercase letters
Only keywords in ActionScript are case sensitive; with the rest of ActionScript, you can use
uppercase and lowercase letters interchangeably. For example, the following statements are
equivalent:
cat.hilite = true;
CAT.hilite = true;
However, it’s good practice to follow consistent capitalization conventions, such as those used in
this manual, to make it is easier to identify names of functions and variables when reading
ActionScript code.
Because ActionScript is not case sensitive, you must not use variable names that match built-in
ActionScript objects. For example, the following is not allowed:
date = new Date();
Instead, use the variable names myDate, theDate, and so on.
If you don’t use correct capitalization with keywords, your script will have errors. When Colored
Syntax is turned on in the Actions panel, keywords written with correct capitalization are blue by
default. For more information, see “Keywords” on page 216 and “About syntax highlighting”
under Help > Using Flash.
Comments
In the Actions panel, use comments to add notes to scripts. 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.
When you choose the comment action, the characters // are inserted into the script. Even a simple
script is easier to understand if you make notes as you create it:
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();
}
|
|
|
|
|
|
| Link Partners: Asia florist, Flowers to India, Hong kong flowers, Site submit, Cheap web hosting, China florist, Japan florist |
|