AddThis Social Bookmark Button
 Naming conventions in actionscript (part 3)


Naming interfaces

Starting interface names with an uppercase "I" helps you distinguish an interface from a class. The following interface name, IEmployeeRecords, uses an initial uppercase letter and concatenated words with mixed case, as follows:

interface IEmployeeRecords{}

The following conventions also apply:

  • Interface names have an uppercase first letter. This is the same as class names.
  • Interface names are usually adjectives. Printable is a good example.

Naming custom components

Component names have an uppercase first letter, and any concatenated words are written in mixed case.

For example, the following default user-interface component set uses concatenated words and mixed case:

  • CheckBox
  • ComboBox
  • DataGrid
  • DateChooser
  • DateField
  • MenuBar
  • NumericStepper
  • ProgressBar
  • RadioButton
  • ScrollPane
  • TextArea
  • TextInput
Components that do not use concatenated words begin with an uppercase letter.

If you develop custom components, use a naming convention to prevent naming incompatibilities with Adobe components. The names of your components must be different from those of the default set that is included with Flash. If you adopt your own consistent naming convention, it helps you prevent naming conflicts.

Remember that the naming conventions in this section are guidelines. It is most important to use a naming scheme that works well for you and to use it consistently.


Avoiding reserved words or language constructs

When naming instances and variables, avoid using reserved words, which can cause errors in your code. Reserved words include keywords in the ActionScript language.

Also,
do not use any word in the ActionScript 2.0 languages (called a language construct) as an instance or variable name. ActionScript constructs include class names, component class names, method and property names, and interface names.

Never use different cases to avoid conflicting with reserved words. For example, naming an instance of the textfield TextField class (which doesn't conflict with TextField because Flash is case-sensitive) is a poor coding practice. The following table lists reserved keywords in ActionScript 2.0 that cause errors in your scripts when used as variable names:

add and break case
catch class continue default
delete do dynamic else
eq extends false finally
for function ge get
gt if ifFrameLoaded implements
import in instanceof interface
intrinsic le it ne
new not null on
onClipEvent or private public
return set static super
switch tellTarget this throw
try typeof var void
while with    

The following words are reserved for future use in Flash, from the ECMAScript (ECMA-262) edition 4 draft language specification. Avoid using these words because they might be used in future releases of Flash.

as abstract Boolean bytes
char const debugger double
enum export final float
goto is long namespace
native package protected short
synchronized throws transient use
volatile      

AddThis Social Bookmark Button
If you think this page is providing useful information, don't hesitate to leave a comment.
flashvalley
 
Copyright ©2006-2008 flashvalley.com - All rights reserved