Coding conventions
101
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.
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
.
NO
T
E
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.
Содержание FLASH MEDIA SERVER 2-DEVELOPING MEDIA
Страница 1: ...Developing Media Applications ...
Страница 6: ...6 ...
Страница 10: ...10 About This Manual ...
Страница 36: ...36 Flash Media Server Architecture ...
Страница 80: ...80 Debugging and Monitoring Applications ...
Страница 106: ...106 Application Development Tips and Tricks ...
Страница 114: ...114 ...