Don't use acronyms and abbreviations.
The exception to this rule is if acronyms or abbreviations represent the standard way to
use a term (such as HTML or CFM). For commonly used acronyms, use mixed cases for
improved readability, such as
Use complementary pairs when you create a related set of variable names.
For example, you might use complementary pairs to indicate a minimum and maximum
game score, as follows:
var minScoreNum:Number = 10; // minimum score
var maxScoreNum:Number = 500; // maximum score
Naming constants
You can use constants for situations in which you need to refer to a property whose value
never changes. This helps you find typographical mistakes in your code that you might not
find if you used literals. It also lets you change the value in a single place.
Variables should be lowercase or mixed-case letters; however, use the following guidelines for
naming static constants (variables that do not change):
Constants should be uppercase.
Separate words should contain underscores.
You can see these guidelines at work in the following ActionScript code snippet:
var BASE_URL:String = "http://www.macromedia.com";
var MAX_WIDTH:Number = 10;
Do not directly code numerical constants unless the constant is 1, 0, or -1, which you might
use in a
loop as a counter value.
for
Naming Boolean variables
Start Boolean variables with the word "is" (because a Boolean value either "is" or "is not"
because of its nature). Therefore, you might use the following for whether a baby is a girl or
not (which is a Boolean value):
isGirl
Or for a variable indicating whether a user is logged in (or not), you might use the following:
isLoggedIn
738
Best Practices and Coding Conventions for ActionScript 2.0
instead of
newHtmlParser
// constant
.
newHTMLParser
// constant
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?