Accessibility
Adobe
Sign in My orders My Adobe

Title

Variable names conflicting with object namesProducts affected

Issue


ActionScript may fail to execute as expected if predefined ActionScript object names are used as variable identifiers.

For example, in the following consecutive lines of ActionScript, the variable named date is declared before a new Date object is created. As a result, the variable now will be undefined when the code is executed.

 date = "July 20th, 1971"; // 'date' contains correct assigned value    now = new Date(); // 'now' will be undefined 

Reason

Use of a variable name that is the same as the name of a predefined ActionScript object causes a name space conflict. As a result, all subsequent calls to the constructor method of the object with that name will not function. A full list of predefined ActionScript objects can be found in the section titled 'Writing Scripts with ActionScript > Using predefined objects' of the ActionScript Reference.

Solution
Using object and variable names specific to the project being coded will help avoid this problem. For example, if the variable date shown in the above example were being used to contain someone's date of birth the variable might be renamed to reflect its use:

 birthDate = "July 20th, 1971"; 

This practice also makes the code more readable.

Solution

Using object and variable names specific to the project being coded will help avoid this problem. For example, if the variable date shown in the above example were being used to contain someone's date of birth the variable might be renamed to reflect its use:

 birthDate = "July 20th, 1971"; 

This practice also makes the code more readable.


Doc ID
(tn_14677)

Last updated
2010-12-28

Products affected

Adobe Community Help

Tags

Contacting Adobe Support

Still need help?
Find out about all your support options.
Contact support