Macromedia flash media server 2-developing media applications User Manual

Page of 114
102
Application Development Tips and Tricks
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.
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");
Object type
Suffix string
Example
Camera
_cam
my_cam
Video
_video
small_video
Microphone
_mic
the_mic
NetConnection
_nc
my_nc
NetStream
_ns
a_ns
SharedObject
_so
myRemote_so