Formatting ActionScript syntax
765
Macromedia recommends the following formatting points to help promote readability in your
ActionScript code.
■
Put one blank line between paragraphs (modules) of ActionScript.
Paragraphs of ActionScript code are groups of logically related code. Adding a blank line
between them helps users read the ActionScript code and understand its logic.
■
Use consistent indentation in your code to help show the hierarchy of the
code’s structure.
Use the same indentation style throughout your ActionScript code, and make sure that
you align the braces (
{}
) properly. Aligned braces improve the readability of your code. If
your ActionScript syntax is correct, Flash automatically indents the code correctly when
you press Enter (Windows) or Return (Macintosh). You can also click the Auto Format
button in the ActionScript editor (the Actions panel or Script window) to indent your
ActionScript code if the syntax is correct.
■
Use line breaks to make complex statements easier to read.
You can format some statements, such as conditional statements, in several ways.
Sometimes formatting statements across several lines rather than across a single line makes
your code easier to read.
■
Include a space after a keyword that is followed by parentheses [
()
].
The following ActionScript code shows an example of this:
do {
// something
} while (condition);
■
Don’t put a space between a method name and parentheses
.
The following ActionScript code shows an example of this:
function checkLogin():Boolean {
// statements;
}
checkLogin();
or
printSize("size is " + foo + "\n");
■
Include a space after commas in a list of arguments.
Using spaces after commas makes it easier to distinguish between method calls and
keywords, as the following example shows:
function addItems(item1:Number, item2:Number):Number {
return (item1 + item2);
}
var sum:Number = addItems(1, 3);
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...