User Guide
10 The Fireworks Object Model
Accessing a Fireworks document
All the functions listed in “Document functions” on page 132 are methods of the Document
object, which represents a Fireworks document. To perform a function on a Document
object, you must first get the Document Object Model (DOM) of the document. You then
call the functions as methods of that DOM.
■ To use a DOM function with a document other than the active document, use the
following syntax; note that
documentIndex is a zero-based index that specifies which
document the command will affect.
fw.documents[documentIndex].functionName();
■ To use a DOM function with the active document, use
fw.getDocumentDOM().functionName() (for more information, see
fw.getDocumentDOM()).
Passing values
For all properties that are not read-only, you can pass values to change elements of a
document. For example, the following command sets the fifth brush in the third open
document to a square shape:
fw.documents[2].brushes[4].shape = "square";
The preceding example includes the following properties:
■ documents is a property of the Fireworks object and contains an array of
Document objects.
■ brushes is a property of the Document object and contains an array of Brush objects.
■ shape is a property of the Brush object.
Fireworks Object Model calls and API calls
In some cases, you can use Fireworks Object Model calls or API calls to perform the same
operations. In other cases, a certain function might be available in either the Fireworks Object
Model or the API, but not in both.
NOTE
You can use methods that operate on a document’s DOM only on open documents.
NOTE
Throughout this manual, optional arguments are enclosed in {braces}.