Adding The Module Tag; Adding Event-Handling Functions - Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide

Adding the module tag

GoLive packages much of its functionality in units known as modules. To add some particular new
functionality to GoLive, a user can install and enable the module that provides it. A GoLive user can also
disable or remove a module to remove its associated features and behaviors.
An extension that you develop using the SDK is simply another kind of module that GoLive can use. Like
the built-in modules, extensions can be enabled and disabled in the Preferences dialog.
Each module must have a unique name that represents it in the global JavaScript namespace. To define
the name of your extension's module, add to your extension's Main.html file a <jsxmodule> tag that
provides a name property:
// Main.html file for Hello example
<html>
<body>
// Tags that define your extension go here.
</html>
When GoLive loads this Main.html file, it creates a module object to represent this extension and sets the
value of the object's name property to the HelloModule string. The presence of the debug attribute
enables debugging services in the JavaScript Debugger window. Always remove the debug attribute from
commercial versions of your extension.
The <jsxmodule> tag and all of its attributes are optional. If you do not supply this tag, or if this tag's name
attribute is missing, GoLive assigns a default value to the name property of the module object it creates to
represent your extension. However, it is recommended that you explicitly define your own <jsxmodule> 's
name attribute so you can use it for debugging purposes.

Adding event-handling functions

The JavaScript functions that provide an extension's behavior reside within its <script> tags. Many of
these functions are event handlers, which you register for particular event target objects. GoLive calls
these functions in response to specific events, such as the GoLive user clicking on something or entering
text. Your extension can provide a handler to respond to a specific event in a specific object, such as the
selection of a menu item or the opening of a document. When the event occurs in a target object, GoLive
looks for all registered handlers for that event in that object, and if it finds one, executes it.
The GoLive CS2 SDK Programmer's Reference provides the names and syntax of all the event and event
target objects, and describes the handlers that you can define. Most of them are optional; you only need to
supply handlers for the events you need to respond to.
Module startup and termination events are handled by functions with predefined names. For example, on
startup, GoLive checks all loaded modules for implementations of the
startModule
The initializeModule function is called as soon as the module is loaded, and can perform any
initialization that does not depend on other modules, and the startModule function is called after all
modules are loaded. Similarly, your implementation of the
housekeeping tasks before GoLive unloads your extension.
<jsxmodule name="HelloModule" debug>
<script>
// functions that provide your extension's behavior go here
</script>
</body>
functions. If your module needs to perform any initialization, it can do it in these functions.
Adobe GoLive CS2
terminateModule
How to Create an Extension
and
initializeModule
function can perform
24

Advertisement

Table of Contents
loading

Table of Contents