About case sensitivity

When you write ActionScript for Flash Player 7 and later, your code is case-sensitive. This means that variables with slightly different capitalization are considered different from each other. The following ActionScript code shows this:

// use mixed capitalization
var firstName:String = "Jimmy";
// use all lower case
trace(firstname); // undefined

Or you could write the following:

// In file targeting Flash Player 8
// and either ActionScript 1.0 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;

NOTE

It is not a good practice to differentiate between variables, or any identifier, using different case. For more information on naming variables, see Best Practices and Coding Conventions for ActionScript 2.0.

When you publish for versions of Flash Player (Flash Player 6 and earlier), Flash traces the string Jimmy in the Output panel. Because Flash Player 7 and later versions are case-sensitive, firstName and firstname are two separate variables (when you use either ActionScript 1.0 or ActionScript 2.0). This is an important concept to understand. If you created FLA files for Flash Player 6 or earlier with nonmatching capitalization in your variables, your functionality and files might break during conversion of the file or application that targets a newer version of the Flash Player.

Therefore, it's good practice to follow consistent capitalization conventions, such as those used in this manual. Doing so also makes it easier to differentiate between variables, classes, and function names. Do not use case to make two identifiers differ. Change the instance, variable, or class name--not just the case. For more information on coding conventions, see Best Practices and Coding Conventions for ActionScript 2.0.

Case sensitivity can have a large impact when you work with a web service that uses its own rules for variable naming and for the case that variables are in when they are returned to the SWF file from the server. For example, if you use a ColdFusion web service, property names from a structure or object might be all uppercase, such as FIRSTNAME. Unless you use the same case in Flash, you might experience unexpected results.

NOTE

Case sensitivity also affects external variables that you load into a SWF file, such as those 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.

Case sensitivity is implemented on a per-SWF file basis. If a strict (case-sensitive) Flash Player 8 application calls a nonstrict Flash Player 6 SWF file, ActionScript executed in the Player 6 SWF file is nonstrict. For example, if you use loadMovie() to load a Flash Player 6 SWF file into a Flash Player 8 SWF file, the version 6 SWF file remains case-insensitive, while the version 8 SWF file is treated as case-sensitive.

When syntax coloring is enabled, language elements written with correct capitalization are blue by default. For more information, see About reserved words.