
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Onward!
|
399
var firstName = "margaret";
var firstname = "michael";
trace(firstName); // Yields "michael"
trace(firstname); // Also yields "michael" (the variables are the same)
Even internal identifiers, such as property names and function names, are not case
sensitive in ActionScript. The following line causes an error in JavaScript but success-
fully creates an array in ActionScript:
myList = new array( ); // Should preferably be new Array( );
This can present problems when porting JavaScript code to ActionScript or for Java-
Script programmers learning ActionScript. Case sensitivity is often used in Java-
Script to apply the same name to different purposes. For example, the statement:
date = new Date( ); // Works in JavaScript but not ActionScript
will have destructive effects in ActionScript where the identifier date is not distin-
guished from the object class Date. In ActionScript, the preceding code disables the
built-in Date class. We must therefore ensure that our identifiers are distinguished by
more than just case, both from one another and from any predefined identifiers, such
as Date or Array. Here’s how we rewrite the previous code in ActionScript:
theDate = new Date( ); // Use this approach in ActionScript
Frame labels and symbol export IDs are also not case-sensitive.