Because ActionScript is based on ECMAScript, application authors can refer to current and
future ECMA specifications to view a list of reserved words. Although Flash does not enforce
the use of constant variables, authors should still use a naming scheme that indicates the
intent of variables. Variable names should be lowercase or mixed case with a lowercase first
letter, and constant names should be all uppercase. For example:
course_list_output = "foo"; // variable, all lowercase
courseListOutput = "foo"; // variable, mixed case
BASEURL = http:// www.foo.com; // constant, all uppercase
MAXCOUNTLIMIT = 10; // constant, all uppercase
MyObject = function(){}; // constructor function
f = new MyObject(); // object
Finally, all SWF files should have names that are lowercase words separated by underscores
(for example, lower_case.swf ). This facilitates moving applications to a case-sensitive
operating system, such as UNIX.
Remember that these syntax recommendations are guidelines. Most importantly, choose a
naming scheme and use it consistently.
Naming variables to support code hinting
The Macromedia Flash ActionScript editor has built-in code hinting support. To take
advantage of this, you can either use strict typing syntax for the variables (new in
ActionScript 2.0) or use a specific format to name the variables. The default format is to add a
suffix to the variable name that indicates the variable type. The following table provides
supported suffix strings.
Object type
Camera
Video
Microphone
NetConnection
NetStream
SharedObject
You can use strict typing syntax for a variable in addition to or instead of using suffixes,
although suffixes have an additional advantage of making your code readable. Many of the
examples throughout this manual use strict typing syntax, such as:
var my_nc:NetConnection = new NetConnection();
var local_so:SharedObject = SharedObject.getLocal("mySO");
102
Application Development Tips and Tricks
Suffix string
_cam
_video
_mic
_nc
_ns
_so
Example
my_cam
small_video
the_mic
my_nc
a_ns
myRemote_so
Need help?
Do you have a question about the FLASH MEDIA SERVER 2-DEVELOPING MEDIA and is the answer not in the manual?