Learning ActionScript 2.0 in Adobe Flash |
|
|
|
| Best Practices and Coding Conventions for ActionScript 2.0 > Naming conventions > 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):
You can see these guidelines at work in the following ActionScript code snippet:
var BASE_URL:String = "http://www.adobe.com"; // constant var MAX_WIDTH:Number = 10; // constant
Do not directly code numerical constants unless the constant is 1, 0, or -1, which you might use in a for loop as a counter value.
|
|
|
|