Adobe 38039927 Extended User Guide - Page 8

The Fireworks Object Model

Page 8 highlights

4 Chapter 2: The Fireworks Object Model If you want to extend the functionality of Adobe Fireworks CS3 by writing or modifying a JavaScript extensibility file, you must become familiar with the objects that Fireworks makes available through JavaScript. The hierarchy of these objects comprises the Fireworks Object Model, which contains the following major components: • Six global methods that are available from any part of the application and need not be declared as methods of a particular object. For more information, see "Global methods" on page 11. • Core objects: Dialogs, Document, pngText, Errors, Files, Find, and System. For more information, see "Core objects" on page 13 and "The Document object" on page 20. (The App object that was used in Fireworks 3 is supported for backward compatibility, but its use is deprecated in favor of the Fireworks object.) • The Fireworks object (for more information, see "The Fireworks Object" on page 170). • Numerous objects associated with Fireworks documents, such as ExportOptions, Guides, Path, Image, and Text. For more information, see "Objects within Fireworks documents" on page 208. • A set of objects that you can use to specify the format of HTML code when exporting from Fireworks. For more information, see "HTML export objects" on page 247. Using the Fireworks Object Model When scripting extensions for Fireworks, you write JavaScript commands that send calls to the Fireworks Object Model to determine or change the current settings for a Fireworks document. For example, the following command calls the Fireworks object (fw) to obtain the path to the Export Settings directory (appExportSettingsDir), which is expressed as a file://URL. In other words, fw references the Fireworks global object, of which appExportSettingsDir is a property (for more information, see "The Fireworks Object" on page 170), so a JavaScript command can assign the resulting value to a variable, as follows: var expSetDir = fw.appExportSettingsDir; Accessing a Fireworks document All the functions listed in "Property inspector functions" on page 294 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. Note: • 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()" on page 188). 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:

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315

4
Chapter 2: The Fireworks Object Model
If you want to extend the functionality of Adobe Fireworks CS3 by writing or modifying a JavaScript extensibility
file, you must become familiar with the objects that Fireworks makes available through JavaScript. The hierarchy of
these objects comprises the Fireworks Object Model, which contains the following major components:
Six global methods that are available from any part of the application and need not be declared as methods of a
particular object. For more information, see “Global methods” on page 11.
Core objects: Dialogs, Document, pngText, Errors, Files, Find, and System. For more information, see “Core
objects” on page 13 and “The Document object” on page 20. (The App object that was used in Fireworks 3 is
supported for backward compatibility, but its use is deprecated in favor of the Fireworks object.)
The Fireworks object (for more information, see “The Fireworks Object” on page 170).
Numerous objects associated with Fireworks documents, such as ExportOptions, Guides, Path, Image, and Text.
For more information, see “Objects within Fireworks documents” on page 208.
A set of objects that you can use to specify the format of HTML code when exporting from Fireworks. For more
information, see “HTML export objects” on page 247.
Using the Fireworks Object Model
When scripting extensions for Fireworks, you write JavaScript commands that send calls to the Fireworks Object
Model to determine or change the current settings for a Fireworks document. For example, the following command
calls the Fireworks object (
fw
) to obtain the path to the Export Settings directory (
appExportSettingsDir
), which
is expressed as a file://URL. In other words,
fw
references the Fireworks global object, of which
appExportSet-
tingsDir
is a property (for more information, see “The Fireworks Object” on page 170), so a JavaScript command
can assign the resulting value to a variable, as follows:
var expSetDir = fw.appExportSettingsDir;
Accessing a Fireworks document
All the functions listed in “Property inspector functions” on page 294 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.
Note:
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()” on page 188
).
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: