Understanding Global Variables in Flash
ActionScript allows you to create global variables, which are variables that are accessible on every Timeline and scope within a Flash document. You'll use some in this project's menu.By putting variables in the global scope, you don't have to worry about providing a fully qualified path to a function in a specific scope. Global variables also allow you to modify values directly rather than having to pass them to a function as an argument and return the modified values. To create a global variable, you use the identifier _global before you type the variable name. You do not use the var syntax when you create a global variable; therefore, to create a global variable, you could type the following:
Chapter 6 on ActionScript fundamentals.
_global.myVariable = 10;
Exercise 2: Setting global variables
The dynamic menu system uses certain global variables to track the current X coordinate where the next button should be placed. After you add each navigation button to the Stage and position it, the variable containing the X coordinate increments (increases) by the width of the button. This helps ensure that no buttons overlap.

1. Select frame 1 of the actions layer; then add the following code to the first line of the Actions panel:
This line of ActionScript declares a variable named navXPos in the _global scope and assigns a value of 20.2. You can see the variables defined in the _global scope in a few different ways. The easiest way to view global variables is to test the current Flash document in the authoring environment and then select Debug > List Variables. Flash launches the Output panel and displays the following text:
_global.navXPos = 20;
Global Variables:
Variable _global.navXPos = 20
Level #0:
Variable _level0.$version = "WIN 7,0,19,0"
Movie Clip: Target="_level0.my_mc"

The Debugger Panel
You can also view global variables using Flash's Debugger panel. To launch the debugger, select Control > Debug Movie. This is the same as using Control > Test Movie, except that Flash displays the Debugger panel. This panel lets you view and change variables within your SWF file. Before you can view global variables, you first need to start the debugger by pressing the Continue button in the Debugger panel. By default, the debugger is paused so you can set breakpoints in your code. When the debugger starts, Flash stops on any line of code that has a breakpoint set. A breakpoint allows you to pause the playback of a SWF file to view which variables are set, as well as their current value in the SWF. This helps make debugging in your Flash document much easier if you're experiencing unexpected results in your documents.Because the _global scope is technically an object, you can also loop over the structure using a for..in loop to display all the global values, as shown in the following code example:
for (var item in _global) {
trace(item+": "+_global[item]);
}