***Naming conventions - You will usually use about 80% of your time troubleshooting, debugging, and performing maintenance on your game.
**General naming guidelines - Use upper and lower case letters to distinguish names of items.
**Avoiding reserved words and language constructs - Don't use reserved words because it can cause an error.
**Naming variables - Start variables with a lowercase letter.
Names with capital first letters are reserved for classes, interfaces, and so on.
**Naming constants - Variables should be lowercase or mixed-case letters.
**Naming Boolean variables - Start Boolean variables with the word "is".
**Naming functions and methods - Name methods as verbs.
**Naming classes and objects - Use meaningful and simple names that are descriptive of the class contents. To avoid being vague or misleading, use generic names.
**Naming packages - Put the prefix for a package name in all lowercase letters.
**Naming interfaces - Interface names are usually adjectives.
**Naming custom components - Components that do not use concatenated words begin with an uppercase letter.
***Using comments in your code - Comments document the decisions you make in the code.
**Writing good comments - Use block comments (/* and */) for multiline comments and single-line comments ( // ) for short comments.
**Adding comments to classes - The two kinds of comments in a typical class or interface file are documentation comments and implementation comments.
***ActionScript and Flash Player optimization - No case sensitivity is involved with the code, only Flash Player.
***ActionScript coding conventions - Consistency is one of the most important aspects of programming.
**Keeping your ActionScript code in one place - Code is easy to find in a potentially complex source file.
**Attaching code to objects - ActionScript code that is attached to objects encourages poor coding style.
**Handling scope - The global scope applies to all timelines and scopes within SWF files.
*About variables and scope - A variable's scope refers to the area in which the variable is known (defined) and can be referenced.
*About scope and targeting - The nested instance is known as the child instance.
*Understanding classes and scope - If you have a class method that uses a callback function (such as the LoadVars class's onLoad() method), it can be difficult to know whether the keyword refers to the class or to the LoadVars object.
**Structuring a class file - You create classes in separate ActionScript 2.0 files that are imported into a SWF file when you compile an application.
**About using functions - One way you can reuse code is by calling a function multiple times, instead of creating different code each time.
***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.
**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.
**Writing conditional statements - Use braces ({}) for if statements.
**Writing compound statements - Compound statements contain a list of statements within braces ({}).
**Writing a for statement - You can write the for statement using the following format:
for (init; condition; update) {
// statements
}
**Writing while and do..while statements - You can write do-while statements using the following format:
do {
// statements
} while (condition);
**Writing return statements - Don't use parentheses [()] with any return statements that have values.
**Writing switch statements - All switch statements include a default case.
**Writing try..catch and try..catch..finally statements - Write try..catch and try..catch..finally statements using the following formats:
var myErr:Error;
// try..catch
try {
// statements
} catch (myErr) {
// statements
}
// try..catch..finally
try {
// statements
} catch (myErr) {
// statements
} finally {
// statements
}
**About using listener syntax - You can write listeners for events in several ways in Flash 8 and later.
Friday, January 29, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment