764
Best Practices and Coding Conventions for ActionScript 2.0
Formatting ActionScript syntax
Formatting ActionScript 2.0 code in a standardized way is essential to writing maintainable
code, and it’s easier for other developers to understand and modify. For example, it would be
extremely difficult to follow the logic of a FLA file that has no indenting or comments, as well
as inconsistent naming conventions and formatting. By indenting blocks of code (such as
loops and
if
statements), you make the code easy to read and debug.
For more information on formatting code, see the following topics:
■
“General formatting guidelines” on page 764
■
“Writing conditional statements” on page 767
■
“Writing compound statements” on page 768
■
“Writing a for statement” on page 769
■
“Writing while and do..while statements” on page 770
■
“Writing return statements” on page 770
■
“Writing switch statements” on page 770
■
“Writing try..catch and try..catch..finally statements” on page 771
■
“About using listener syntax” on page 772
General formatting guidelines
When you use spaces, line breaks, and tab indents to add white space to your code, you
increase your code’s readability. White space enhances readability because it helps show the
code hierarchy. Making your ActionScript 2.0 easier to understand by making it more
readable is important for students as well as for experienced users working on complex
projects. Legibility is also important when you are debugging ActionScript code, because it is
much easier to spot errors when code is formatted correctly and is properly spaced.
You can format or write a piece of ActionScript 2.0 code several ways. You’ll find differences
in the way developers choose to format the syntax across multiple lines in the ActionScript
editor (the Actions panel or Script window), such as where you put brackets (
{}
) or
parentheses [
()
]).
Содержание 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...