Lingo Dictionary > G-K > global

 

global

Syntax

global variable1 {, variable2} {, variable3}...

Description

Keyword; defines a variable as a global variable so that other handlers or movies can share it.

Every handler that examines or changes the content of a global variable must use the global keyword to identify the variable as global. Otherwise, the handler treats the variable as a local variable, even if it is declared to be global in another handler.

Note: To ensure that global variables are available throughout a movie, declare and initialize them in the prepareMovie handler. Then, if you leave and return to the movie from another movie, your global variables will be reset to the initial values unless you first check to see that they aren't already set.

A global variable can be declared in any handler or script. Its value can be used by any other handlers or scripts that also declare the variable as global. If the script changes the variable's value, the new value is available to every other handler that treats the variable as global.

A global variable is available in any script or movie, regardless of where it is first declared; it is not automatically cleared when you navigate to another frame, movie, or window.

Any variables manipulated in the Message window are automatically global, even though they are not explicitly declared as such.

Shockwave movies playing on the Internet cannot access global variables within other movies, even movies playing on the same HTML page. The only way movies can share global variables is if an embedded movie navigates to another movie and replaces itself through either goToNetMovie or go movie.

Example

This example sets the global variable StartingPoint to an initial value of 1 if it doesn't already contain a value. This allows navigation to and from the movie without loss of stored data.

global gStartingPoint
on prepareMovie
	if voidP(gStartingPoint) then gStartingPoint = 1
end

See also

showGlobals, property, gotoNetMovie