Flash Tutorial - AS Coding standards (Good coding guide)

ActionScript Coding Standards

Macromedia Flash applications have generally been built without regard to particular standards or guidelines. While this flexibility allows for a wide variety of solutions to a problem, it also makes it difficult for anyone other than the author of an application to understand the code. Even the author may have difficulty reading his or her own code after it is written. If a developer cannot understand the code in an application, it will not be easy to debug the code, make changes, or reuse.

This documents outlines a system of best practices specifically designed for coding with ActionScript and building applications with Macromedia Flash. Applications that use these guidelines should be more efficient and understandable-and the underlying ActionScript code will be easy to debug and reuse.

Naming guide lines

Most importantly, an application’s naming scheme must be consistent and names should be chosen for readability. This means that names should be understandable words or phrases. The primary function or purpose of any entity should be obvious from its name. Since ActionScript is a dynamically typed language, the name should also contain a suffix that defines the type of object being referred to by the name. In general, “noun-verb” and “adjective-noun” phrases are the most natural choice for names.

For Example

Movie name - my_movie.swf

entity appended to a URL - course_list_output

component or object - ProductInformation

variable or property - userName

Function names and variables should begin with a lower case letter. Objects, and object constructors, should be capitalized. Using mixed case is also recommended when naming variables, although other formats are acceptable as long as they are used consistently within the application.

Variable names can only contain letters, numbers and underscores. However, do not begin variable names with numbers or underscores.

Examples of illegal variable names

Read more at adobe

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • YahooMyWeb
  • Furl
  • Spurl
  • Technorati

Leave a Comment