Coding Conventions; Following Naming Guidelines - MACROMEDIA FLASH MEDIA SERVER 2-DEVELOPING MEDIA Develop Manual

Developing media applications
Table of Contents

Advertisement

Coding conventions

This document 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 is easy to debug and reuse.
You can use ActionScript 1 or 2 to write client-side scripts. You can use ActionScript 1 or
JavaScript 1.5 to write server-side scripts.

Following naming guidelines

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. Because ActionScript 1 is
a dynamically typed language, the name should also contain a suffix that defines its type. In
general, noun-verb and adjective-noun phrases are the most natural choices for names. For
example:
Application name (SWF file): my_movie.swf
Entity appended to a URL: course_list_output
Component or object: ProductInformation
Variable or property: userName
Begin function names and variables with a lowercase letter. Capitalize objects and object
constructors. Use mixed case (uppercase and lowercase) when you name variables, although
other formats are acceptable as long as they are used consistently within the application.
Variable names can contain only letters, numbers, and underscores. However, do not begin
variable names with numbers or underscores.
Examples of unacceptable variable names:
_count = 5; // begins with an underscore
5count = 0; // begins with a number
foo/bar = true; // contains a forward slash
foo bar = false; // contains a space
In addition, never use as names words that ActionScript uses (reserved words). Also avoid
using variable names of common programming constructs, even if the Macromedia Flash
Player does not currently support those constructs. This practice helps to ensure that future
versions of the Player will not conflict with the application. For example, do not use
commands such as
MovieClip = "myMovieClip"
or
.
case = false
Coding conventions
101

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MEDIA SERVER 2-DEVELOPING MEDIA and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash media server 2

Table of Contents