Introduction to ActionScript3

When selecting a name for a symbol or other object follow these rules:

  • A valid name must start with a letter of the alphabet.
  • After the first letter, there can be additional letters, digits and underscores.
  • There cannot be any spaces in a name.
  • Words that have a special meaning such as play, stop, or width cannot be used as a name.
  • A name should indicate its purpose. Names like symbol1, untitled, and single letters are not good names.
  • If two words are joined together (you can't have any spaces), a capital letter for the second word or an underscore can improve the clarity. Example: hoursWorked, state_tax, and dueDate are all good names.
  • Remember, ActionScript is case sensitive. If an instance is named laserGun it must be written exactly the same way each time it is used. LaserGun, lasergun, and laserGun are all different names.
  • When you create a movie clip, name the instance in the library with the first letter in upper case. Name the instance on the stage with the first letter in lower case.
  • It will be easier to remember the names if you develop a particular style and stick to it. The examples here will usually use a lower case letter for the first word, and capitalize the first letter of the other words. (This style is sometimes called camel case.)
Determine if each name below is a valid variable name. Put the mouse over the check mark to see if you are right.

1. ball OK

2. ball 1 NO! ball1 is OK, but you can not have a space.

3. 1Fish NO! A name must start with a letter.

4. bad_dude OK The underscore is OK.

5. a123 OK

6. a1-b2 NO! The only special character that you can use is the underscore.

7. x NO! You can not use properties of a movie as names.

8. stop NO! You can not use words with special meanings (reserved words) in ActionScript as names.

NEXT: Stop!