Scope Of Variables And Functions - Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide

Scope of Variables and Functions

You use standard JavaScript syntax to define your extension's variables and functions. When a Main.html
file defines a "global" variable or function, GoLive actually creates the variable or function within the scope
of the extension module the file defines, not in the JavaScript global namespace. It is available within the
execution scope of that module. It is not available to other extensions.
The only truly global values in the GoLive JavaScript environment are those provided by system-defined
global variables such as the app variable and the document variable. These properties are available to
every extension. For a complete listing and description, see
GoLive CS2 SDK Programmer's Reference.
To demonstrate variable scope in the JavaScript Debugger window, add the following highlighted lines to
the Main.html file that you created in
// Main.html file for Hello example
<html>
<body>
<jsxmodule name="HelloModule" debug>
</body>
</html>
The new code just adds another writeln statement, but packages it as an extension-specific function.
From within the body of this function, the myGlobal variable is accessible as a global variable. However, it
is not accessible to any other modules.
The JavaScript Debugger shows the current scope in its module list. To set the execution scope to the
HelloModule extension, choose its module name from the pulldown menu, as shown here.
Adobe GoLive CS2 SDK
<script>
var myGlobal = "Hamburg, Liverpool, and London."
function fabFour()
{
writeln ("The Fab Four played in " + myGlobal);
}
function initializeModule()
{
writeln ("Loading the " + module.name + " extension.");
fabFour();
}
function terminateModule()
{
Window.alert ("Unloading the " + module.name + "extension.")
}
</script>
Appendix E, "Scoping in JavaScript
Chapter 2, "How to Create an
The JavaScript Environment
Extension, " and restart GoLive.
31
in the

Advertisement

Table of Contents
loading

Table of Contents