User Guide

28 Chapter 2: ActionScript Basics
Syntax
As with all scripting languages, ActionScript has syntax rules that you must follow to create scripts
that can compile and run correctly. This section describes the elements that comprise
ActionScript syntax:
“Case sensitivity” on page 28
“Dot syntax” on page 29
“Slash syntax” on page 30
“Curly braces” on page 30
“Semicolons” on page 31
“Parentheses” on page 31
“Comments” on page 31
“Keywords and reserved words” on page 32
“Constants” on page 34
Case sensitivity
In a case-sensitive programming language, variable names that differ only in case (
book and Book)
are considered different from each other. Therefore, its good practice to follow consistent
capitalization conventions, such as those used in this manual, to make it easy to identify names of
functions and variables in ActionScript code.
When you publish files for Flash Player 7 or later, Flash implements case sensitivity whether you
are using ActionScript 1 or ActionScript 2.0. This means that keywords, class names, variables,
method names, and so on are all case sensitive. For example:
// In file targeting Flash Player 7
// and either ActionScript 1 or ActionScript 2.0
//
// Sets properties of two different objects
cat.hilite = true;
CAT.hilite = true;
// Creates three different variables
var myVar:Number=10;
var myvar:Number=10;
var mYvAr:Number=10;
// Does not generate an error
var array:Array = new Array();
var date:Date = new Date();
This change also affects external variables loaded with LoadVars.load().
Case-sensitivity is implemented for external scripts, such as ActionScript 2.0 class files, scripts
that you import using the
#include command, and scripts in a FLA file. If you encounter
runtime errors and are exporting to more than one version of Flash Player, you should review
both external script files and scripts in FLA files to confirm that you used consistent
capitalization.