Flash AS3 Basics: Identifiers

Identifiers are the names that you invent to represent or identify elements in the program. Identifiers can be used to name MovieClip instances, Classes, Variables and Functions.

The program comes with many built elements that already have names. These are things like MovieClip methods like gotoAndStop() etc. You should avoid using these names as names for your own elements.

When creating Identifier names you should follow the following rules.

  • Names must begin with a letter (a,b,c etc) the underscore (_) or the dollar sign ($).
  • Names can contain any combination of letters, numbers and the underscore and dollar sign.
  • Avoid using names have already been used by the program.

Conventions

Identifiers are used fro various purposes. Following conventions while creating identifier names will help you keep them all straight.

In general identifiers should be kept lower case.

Class names: Class names always begin with an upper case letter. All of the built in classes follow this convention. For example MovieClip, Sprite and EventDispatcher all start with an uppercase letter.

Private Properties: A common convention is to start private properties with an underscore. For example: _index, _width, _height etc. The definitions for these might look like:

private var _index:uint;
private var _width:Number;
private var _height:Number;