About variables and scope

A variable's scope refers to the area in which the variable is known (defined) and can be referenced. The area in which the variable is known might be within a certain timeline or inside a function, or it might be globally known throughout the entire application.For more information about scope, see About scope and targeting.

Understanding variable scope is important when you develop Flash applications with ActionScript. Scope indicates not only when and where you can refer to variables but also for how long a particular variable exists in an application. When you define variables in the body of a function, they cease to exist as soon as the specified function ends. If you try to refer to objects in the wrong scope or to variables that have expired, you get errors in your Flash documents, which lead to unexpected behavior or broken functionality.

There are three types of variable scopes in ActionScript:

For guidelines on using scope and variables, see About scope and targeting.

NOTE

 

ActionScript 2.0 classes that you create support public, private, and static variable scopes. For more information, see About class members and Controlling member access in your classes.

You cannot strict type global variables. For information and a workaround, see Global variables.


Version 8

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00001200.html