Friday 3 October 2008

Naming conventions in Flash

There are a whole load of programming conventions that make using actionscript a little easier.  I found this article on the adobe website that explains in detail what you should and shouldn't do.  Here is a bullet-pointed quick start.

  • Use consistent abbreviations - ply for player, and plw for plywood, for example.
  • Use mixed-cases to make words stand out - like brainHead.
  • Try and be descriptive - brnSc is not as good brainScanner.  And aZebFrmA is useless compared to aZebraFromAfrica.
  • Actually it says the shorter the name the better - so what about africanZebra.
  • Obviously you can't use words already in actionscript, so var, array, new etc. are all banned.
  • Variables can't start with a number
  • Functions should start with a lower case letter
  • Classes and objects should start with upper case characters - this helps them stand out in your code so that when you see MonkeyWidget you know that it refers to a homemade class.
There is loads more in this article, but these few tips should help you keep out of trouble for a little while.

No comments: