To extend Adobe® Fireworks® CS5, you must write JavaScript code. You can use JavaScript to write your own objects
and commands that affect Fireworks documents and the elements within them. To accomplish these tasks, you must
be proficient in JavaScript and in Fireworks.
This guide introduces the Fireworks Object Model, explains how to write cross-product extensions (extensions written
in, or for, other Adobe applications), and discusses the JavaScript Auto Shape construction. The final chapter is a
reference to the Fireworks JavaScript application programming interface (API)—the custom JavaScript functions that
are built into Fireworks.
Prerequisites
Because Fireworks extensions must be written in JavaScript, this guide assumes that readers are familiar with
JavaScript syntax and with basic programming concepts such as functions, arguments, and data types. It also assumes
that readers understand the concept of working with objects and properties. This guide does not attempt to teach
programming in general or JavaScript in particular.
1
Anyone who wants to extend Fireworks should have a good JavaScript reference to help with syntax questions (for
example, is it
Goodman (IDG), JavaScript: The Definitive Guide by David Flanagan (O’Reilly), and Pure JavaScript by R. Allen
Wyke, Jason D. Gilliam, and Charlton Ting (Sams).
substring() or subString()?). Useful JavaScript references include JavaScript Bible by Danny
Installing an extension
As you start learning the process of writing extensions, you might want to explore the extensions and resources already
available through the Adobe Exchange website
you will become familiar with some of the tools that you need to work with your own extensions.
To install an extension:
1 Download and install the Adobe® Extension Manager, which is available on the Adobe Downloads website
www.adobe.com/exchange/em_download/).
(
2 Log on to the Adobe Exchange website (www.adobe.com/go/exchange).
3 Click the Fireworks Exchange link.
4 From the available extensions, choose one that you want to use. Click the Download link to download the extension
package.
5 Save the extension package in a directory on your machine.
6 In Fireworks, choose Commands > Manage Extensions to start the Extension Manager (or you can start Extension
Manager, located in the Adobe program group, independently from Fireworks).
7 In the Extension Manager, choose File > Install Extension, and choose the extension package you just saved.
The Extension Manager automatically installs the extension into Fireworks.
(www.adobe.com/go/exchange). By installing an existing extension,
Last updated 5/17/2012
EXTENDING FIREWORKS
Extending Fireworks Overview
You cannot begin using some extensions until you restart Fireworks. If you are running Fireworks when you install
the extension, you might be prompted to quit and restart the application.
To view basic information on the extension after its installation, go to the Extension Manager (Commands >
Manage Extensions) in Fireworks.
What’s new in Extending Fireworks CS5
Fireworks CS5 includes the following new features and interfaces that you can use to develop extensions for the
product:
CSS-based layouts Fireworks CS5 now allows you to design complete web pages and export web standards-compliant
CSS-based layouts. You can select a layout and integrate foreground and background graphics with automatic margin
and padding detection. You can drop HTML rich symbols on your Fireworks layouts to specify headings, links, and
form properties for precise CSS control. You can also use rectangles with rounded corners and gradients for creating
layouts.
Adobe Type Engine The new Adobe Type Engine provides enhanced typesetting capabilities similar to Adobe®
Photoshop® and Adobe® Illustrator®. You can import or copy/paste double-byte characters from Illustrator or
Photoshop without loss of fidelity, and create advanced effects such as setting text inside a path.
2
Export to PDF You can generate high-fidelity, interactive, secure PDF documents from your Fireworks design comps
and receive review comments through a shared PDF review.
Smart Guides Use Smart Guides to expertly position and layouts objects on canvas. Use Smart Guides with tool tips
to achieve precise positioning.
Live Styles With Live Styles, you can use professionally designed styles or create your own collection. Enhanced
capabilities include redefining styles, dynamically updating effects, colors, and text attributes by updating the style
source.
FXG export You can export designs as FXG files and use them in advanced design tools to develop rich Internet
applications and experiences that can run on Adobe® Flash Player or Adobe® AIR™.
Adobe AIR export You can package your Fireworks documents as Adobe AIR applications that you can secure using
a digital signature.
The following APIs have been added or modified for this release:
Last updated 5/17/2012
EXTENDING FIREWORKS
Extending Fireworks Overview
ClassProperty or MethodDescription
3
AIRExtAIRext.PreviewDocument()Calls the ADL tool to preview an HTML document as an Adobe AIR
AIRext.PackageApplication()Calls the ADT tool package an Adobe AIR application.
AIRext.CreatePackage()Calls the ADT tool to create a signed AIR package.
AIRext.CheckCertificatePasswor
d()
AIRext.SaveDigSigPassword()Saves the password for the given digital certificate, for the current
AIRext.GetDigSigPassword()Returns the name of the generated password file.
AIRext.GetLastErrorLogName()Returns the name of the generated error log file if one was
AIRext.GetAIRInstallPath()Returns the full system path name and path of the generated file.
AIRext.GetJREVersion()An object with two properties - maxVersion and minVersion; if an
AIRext.CreateCertificate()Calls the ADT to create a self-signed digital certificate.
exportDocisBackgroundSpecifies whether the document has a background image. If an
backgroundAttachmentSpecifies whether the document is fixed or scrolls. Values are
docAlignmentSpecifies the page alignment as left, center, right. Default is left.
application.
Calls the ADT tool to check a certificate password.
session of Fireworks (no persistent storage).
created.
error occurs the values of the maxVersion and minVersion will be
-1.
image is set in the HTML set up, returns true.
Fixed or scroll.
backgroundURLSpecifies the URL of the background image as file:///)
backgroundRepeatSpecifies if the background image repeats, and if repeats in X, Y,
leftMarginSpecifies the left margin of the page.
topMarginSpecifies the top margin of the page.
rightMarginSpecifies the right margin of the page.
bottomMarginSpecifies the bottom margin of the page.
Repeat (Both) and No Repeat
Last updated 5/17/2012
EXTENDING FIREWORKS
Extending Fireworks Overview
ClassProperty or MethodDescription
4
SliceInfobackgroundHorizontalPositionHorizontal position of the background image. (Left, right, or
backgroundVerticalPositionHorizontal position of the background image. (Left, right, or
backgroundHorizontalPositionValHorizontal position value of the background image if the
backgroundVerticalPositionValVertical position value of the background image if the argument
isBackgroundSpecifies whether the slice is background image or foreground
backgroundRepeatSpecifies if the background image repeats, and if repeats in X, Y,
backgroundAttachmentSpecifies if the bg image is fixed or scrolls with the rest of the
RectPrimitiveModeSpecifies the roundness units which can be relative (percentage)
instancetranformSpecifies the transformation matrix of a symbol instance.
symbolNameSpecifies the symbol name.
framenameSpecies the name of the state.
FrameNLayerIntersectionnameSpecifies the name of the layer when the layers are accessed from
center, numeric value)
center, numeric value)
argument is value.
is value.
image. True = Background.
Repeat (Both) and No Repeat.
page.
or exact (pixels).
states.
documentdom.setRectRoundnessMode()Specifies the mode of corner roundness of the rectangle as either
dom.exportElements()Exports an array of elements on the canvas to a 32-bit PNG image,
dom.moveNineScaleGuide()Moves a 9-slice scaling guide’s position by specified pixels.
dom.placeTextInPath()Places the selected text inside the selected path. If no text and
dom.setSliceType()Sets the slice type as image (foreground image), background
dom.redefineStyleByName()Redefines the target style with the source style.
dom.snapToPixel()Snap To Pixel is applied on the selected object on the canvas.
dom.attachTextInPath()Attaches the selected text inside the selected path. If no text and
a percentage value or or exact pixel value.
based on the image export settings.
path are selected, no action occurs.
image, or empty (HTML Slice).
path are selected, no action occurs.
Last updated 5/17/2012
EXTENDING FIREWORKS
Extending Fireworks Overview
ClassProperty or MethodDescription
5
fwfw.saveAs()Saves the specified document in the specified filename and
fw.exportPDF()Exports the specified document to the specified file in PDF
fw.exportFXG()Exports current page, all pages of the open document in
fw.exportPages()Exports the specified pages in the specified format.
fw.shrinkPIWindow()Minimizes the Property inspector window.
fw.setUseAGMRenderingForSele
ction()
fw.currentWorkspaceName()Returns the name of the current workspace layout.
fw.getFamilyNameForPSFont()Gets the family name of a PostScript font.
fw.getPlatformNameForPSFont() Returns the platform name of the PostScript font.
“fw.saveDocumentAsTemplate(a
rg1,arg2)” on page 233
“fw.saveDocumentAsTemplateA
sync(arg1,arg2)” on page 234
“fw.newDocumentFromTemplat
e(arg1)” on page 224
“fw.newMobileDocument(arg1,a
rg2,arg3,arg4)” on page 224
format.
format.
Fireworks, or selected objects from the current page as FXG files.
Sets the currently selected vectors to use the new AGM
Rendering.
Saves the current document as a template.
Works the same as fw.saveDocumentAsTemplate() except
for the async mode of save operation.
Opens up a file for selecting any template from the pre-defined
Templates folder in Fireworks installation directory.
Creates a mobile document with the width, height, and
resolution details.
“fw.previewInDeviceCentral()”
on page 227
“fw.getDocumentDOM().InsertP
ageForImport” on page 214
“fw.getDocumentDOM().combin
eCompoundShape” on page 213
“fw.getDocumentDOM().createC
ompoundShape” on page 214
fw.appTemplatesDir (See “The
Fireworks Object” on page 191
“fw.getDocumentDOM().Vector
Operation” on page 215
FileswriteUTF8Writes text in UTF8 encoding when the file is opened in UTF8
readLineUTF8Reads one line from the file that has been opened with UTF8
Launches Adobe Device Central and previews the current
document in it. If there is no active document, an alert message is
generated.
Creates a compound shape from the selected vectors applying
the operation that is specified. Requires two or more vectors to be
selected.
Combines the compound shape that is selected. Requires
selection of a compound shape.
Creates a compound shape from the selected vectors applying
the operation that is specified. Requires two or more vectors to be
selected.
Returns the path of the Templates directory present at the
location where you have installed Fireworks.
Vector operation is applied on paths created after applying this
API. A compound shape is created.
encoding.
encoding.
Last updated 5/17/2012
EXTENDING FIREWORKS
Extending Fireworks Overview
Conventions used in this guide
The following typographical conventions are used in this guide:
• Code font indicates code fragments and API literals, including class names, method names, function names, type
names, scripts, SQL statements, and HTML and XML tag and attribute names.
• Italic code font indicates replaceable items in code.
• The continuation symbol (¬ ) indicates that a long line of code has been broken across two or more lines to fit on
the page. When copying the lines of code, eliminate the continuation symbol and type the code as one line.
• Curly braces ({ }) around a function argument indicate that the argument is optional.
The following naming conventions are used in this guide:
• You refers to the developer who is responsible for writing extensions.
• The user refers to the person using Fireworks.
• The visitor refers to the person who views the graphic that the user created.
Additional resources for extension writers
6
To communicate with other developers who are writing extensions, you can visit the Adobe online forums at
www.adobe.com/support/forums/.
Last updated 5/17/2012
Chapter 2: The Fireworks Object Model
If you want to extend the functionality of Adobe Fireworks CS5 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
• Core objects: Dialogs, Document, pngText, Errors, Files, Find, and System. For more information, see “Core
objects” on page 17 and “The Document object” on page 28. (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 191).
• Numerous objects associated with Fireworks documents, such as ExportOptions, Guides, Path, Image, and Text.
For more information, see
• 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 277.
“Objects within Fireworks documents” on page 243.
“Global methods” on page 14.
7
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 (
expressed as a file://URL. In other words,
is a property (for more information, see
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 321 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.
When accessing a Fireworks document, consider the following points:
• 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) to obtain the path to the Export Settings directory (appExportSettingsDir), which is
fw references the Fireworks global object, of which appExportSettingsDir
“The Fireworks Object” on page 191), so a JavaScript command can assign the
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:
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
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.
Note: Throughout this manual, optional arguments are enclosed in {braces}.
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.
For example, if the first open document is the current document, the first code fragment has the same effect as the
second and third code fragments. The
information, see
fw.getDocumentDOM() function references the current document (for more
8
Formatting nonstandard data types
In addition to the standard data types that can be passed to functions as arguments, or used as properties, such as
integer, string, and so on, Fireworks accepts other data types.
• Some functions accept values that are Fireworks objects. For more information, see “The Fireworks Object Model”
on page 7.
• Some functions accept a string in a specific format. Others accept value types that are not Fireworks objects but are
JavaScript object types that are specific to Fireworks. These types of arguments are described next, in alphabetical
order.
Color string data type
Functions that accept colors as arguments use the HTML syntax "#rrggbb". You can specify a color with an alpha
(transparency) component by passing a longer string of the form
Mask data type
The format for a mask is {maskBounds:rectangle, maskKind:string, maskEdgeMode:string, featherAmount:int,
maskData:
• maskBounds specifies the bounding rectangle of the mask area.
• Acceptable values for maskKind are "rectangle", "oval", "zlib compressed", "rle compressed", or
• If the value of maskKind is "rectangle" or "oval", the maskData string is ignored, and a mask of the right shape is
• If the value of maskKind is “zlib compressed“, “rle compressed", or “uncompressed", the maskData string is
hex-string}.
"uncompressed".
constructed that fills maskBounds and that has the edge specified by maskEdgeMode and featherAmount.
presumed to contain 8-bit mask data in hexadecimal format that precisely matches the maskBounds to define the
mask.
"#rrggbbaa".
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
Matrix data type
The format for a matrix is {matrix:[float, float, float, float, float, float, float, float, float]}.
This guide assumes that you know how to use these nine values to construct a three-by-three transformation matrix;
discussion of the construction of transformation matrices is beyond the scope of this manual.
Point data type
The format for a point is {x:float, y:float}. For instance, dom.addNewLine(startPoint, endPoint) could look like
the following example:
Three categories of API functions are described in this book: Document functions, History panel functions, and
Fireworks functions. The following rules apply to all functions.
Zero-based indexes
Some functions take an index argument which is a zero-based, one-dimensional array. That means a value of 0
represents the first item in the array,
deletes the second layer of the active Fireworks document:
fw.getDocumentDOM().deleteLayer(2);
Functions that take a frameIndex argument can be passed –1 to indicate the current frame. Similarly, functions that
take a layerIndex argument may be passed –
Passing null values
In general, passing a null value to a function causes an exception to be thrown. A few functions do allow null as an
argument; such cases are noted in the function descriptions.
1 represents the second item, and so on. For example, the following command
1 to indicate the current layer.
Working with selected elements
Many API functions in this chapter refer to a “selection” or to “selected items.” These terms refer to Fireworks
elements, such as text boxes or images, that are currently selected. In most cases, the functions work even if only one
item is selected. If a function requires more than one selected item, this is noted in the description of the function.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
Palette or panel
Several API functions reference the History panel (see “History panel functions” on page 324). Throughout the
Fireworks documentation and online help, the term palette is reserved for discussions of a color palette, and the term
panel is used to refer to the floating windows that are available within Fireworks. Therefore, when the function name
contains palette, the descriptions refer to a panel.
Using the common API
You can use the common Adobe API if you want commands to use a common syntax (and thus run a single command
in multiple applications). You can access this API using
supported in Fireworks and Dreamweaver to let developers easily create commands for both applications.
app.toggleFloater()
Identical to fw.toggleFloater().
app.setFloaterVisibility()
Identical to fw.setFloaterVisibility().
app.methodName().The following methods are currently
10
app.getRootDirectory()
Identical to the Fireworks object property appDir •.
app.browseDocument()
Identical to fw.browseDocument().
Note: The app.getRootDirectory() function is useful if you want to use app.browseDocument() to view files within the
applications’s folder.
Working with selected objects
When an object is selected, either programmatically (for example, using the dom.selectAll() function) or by a user,
you can return (get) or set the value of that object’s properties using common notation that will work on various
objects. In other words, you can write a command that will get or set the value of an object’s properties whether the
user selects a Text object, or an Image object, or any other recognized object. In Fireworks, a recognizable object is
classified as one of the following element types:
• Hotspot
• SliceHotspot (basically, a slice)
• Path
• Group
• Instance
• Text
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
• RectanglePrimitive
• PathAttrs
• Image
To test whether a text block is selected, type the following code:
firstSelection = fw.selection[0];
if (firstSelection == "[object Text]"){
alert("I am a text block");
}
You can use the information in the following sections to return or set property values.
Note: The return value for a property may be null.
Working with properties for any selected object
You can get values for the following read-only properties of any type of selected object:
• top
• left
• width
• height
• visible
• opacity
• blendMode
• name
• mask
To return the name of the selected object, type the following code:
11
objectName=fw.selection[0].name;
The following properties contain other read-only properties that you can return:
elementMask
• element
• linked
• enabled
• mode
• showAttrs
• autoExpandImages
effectList
• name
• effects
To return the name of the first effect that is applied to the selected object, type the following code:
Working with specific properties for selected elements
Some elements have specific properties that can be returned in addition to those that can be returned for any selected
object (for more information, see
properties are available for each of the following elements when the elements are selected.
Hotspot
• shape
• urlText
• altText
• targetText
• contour
• behaviors (returns an array of behaviors)
• color
To return the alt tag that has been applied to the currently selected Hotspot, type the following code:
altTag = fw.selection[0].altText;
“Working with properties for any selected object” on page 11). These specific
12
SliceHotspot
SliceHotspot is a subclass of Hotspot. A slice has all Hotspot properties, plus the following properties:
• baseName
• htmlText
• tdTagText
• sliceKind ("image" or "empty")
• exportOptions
• sliceID (read-only)
To return the name of the currently selected slice, type the following code:
sliceName = fw.selection[0].baseName;
Path
• pathAttributes
Note: For the complete list of path attributes properties, see “pathAttributes” on page 98.
• randSeed
• textureOffset
• contours
To return the value of the fill color for the currently selected path, type the following code:
The following are the global Fireworks methods, along with their argument data types and, where appropriate,
acceptable values and notes.
alert(message)
Availability
Fireworks 3.
Usage
alert(message)
Arguments
message A string containing the message to display.
Returns
Nothing.
Description
Displays the message in a modal alert box, along with an OK button.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
confirm(message)
Availability
Fireworks 3.
Usage
confirm(message)
Arguments
message A string containing the message to display.
Returns
True if OK is clicked, false if Cancel is clicked.
Description
Displays a string in a modal alert box, along with OK and Cancel buttons.
prompt(caption, text)
15
Availability
Fireworks 3.
Usage
prompt(caption, text)
Arguments
caption A string containing the title of the dialog box.
text A string containing the prompt for the user.
Returns
The string entered if OK is clicked, null if Cancel is clicked.
Description
Prompts the user (with the string that is specified by text) to enter a string in a modal dialog box; the dialog box is titled
with the string that is specified by caption.
write(arg1, arg2, ..., argN)
Availability
Fireworks 3.
Usage
write(arg1, arg2, ..., argN)
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
Arguments
arg1, arg2, ..., argN Strings containing content for output.
Returns
An output file.
Description
Same as WRITE_HTML; WRITE_HTML was created to let you differentiate HTML output calls from other JavaScript
calls in your code.
WRITE_CSS
Availability
Fireworks 3.
Usage
WRITE_CSS
16
Arguments
None.
Returns
An output file.
Description
Available only when exporting. Writes the CSS as an external file.
WRITE_HTML(arg1, arg2, ..., argN)
Availability
Fireworks 3.
Usage
WRITE_HTML(arg1, arg2, ..., argN)
Arguments
arg1, arg2, ..., argN Strings containing content for output.
Returns
An output file.
Description
Available only when exporting. Converts each argument to a string and writes it to the HTML output file. To enter an
end-of-line character, use “\n”; this is converted to the correct line ending for your platform. For more information,
“HTML export objects” on page 277.
see
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
fw.setUseAGMRenderingForSelection()
Availability
Fireworks 10.
Usage
fw. setUseAGMRenderingForSelection()
Arguments
A boolean value that defines whether AGMRendering is used or not.
Returns
Nothing.
Description
Sets the currently selected vectors to use the new AGM Rendering.
This section describes the set of core objects that are always available: Errors, Files, Find, and System. The Document
object is described within its own chapter: see
Note: For information on how to format nonstandard data types, such as rectangle or point, see “Formatting
nonstandard data types” on page 8.
Errors object
All Errors object properties are read-only strings that are used to simplify the localizing of scripts. They return
localized error messages appropriate to the specific error. For example, the English version of Fireworks returns
"Memory is full." for the EOutOfMem property.
The following list contains the properties of the Errors object alphabetically:
The following table lists the methods of the Files object, along with their data types and, where appropriate, acceptable
values and notes.
“The Document object” on page 28.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
MethodData typeNotes
18
copy(docname1, docname2)
createDirectory(dirname)
createFile(fileURL,
fileType, fileCreator)
deleteFile(docOrDir)
deleteFileIfExisting
(docOrDir)
enumFiles(docOrDir)
string, stringCopies the file specified in the first argument to the file
specified in the second argument. Each argument must be the
name of a file, which is expressed as file://URL. Only files (not
directories) can be copied. The files do not need to reside on
the same drive, and the method does not overwrite a file if it
already exists. Returns a value of
false otherwise.
true if the copy is successful;
stringCreates the specified directory. Returns true if successful;
false otherwise.
string, string, stringCreates the specified file. The file must not already exist. The
first argument is the name of the file, which is expressed as
file://URL. The last two arguments let you specify the file type
and file creator strings. The
fileType and fileCreator
strings should each be strings of exactly four characters in
length, for example:
Files.createFile(newFile,".txt","FWMX");
stringDeletes the specified file or directory. Returns true if
successful;
false if the file or directory does not exist or
cannot be deleted. Compare with
deleteFileIfExisting().
stringDeletes the specified file or directory. Returns true if
successful;
Unlike
false if the file or directory cannot be deleted.
deleteFile(), this method returns true if the file or
directory does not exist.
stringReturns an array of file URLs. If docOrDir is a directory, the
array contains an entry for every file or directory that is
contained in the specified directory. If
docOrDir is a file, the
array contains a single entry (the file passed in).
exists(docOrDir)
getDirectory(docname)
getExtension(docname)
getFilename(docname)
getLanguageDirectory()
getLastErrorString()
stringReturns true if docOrDir refers to a directory or file that
false otherwise.
exists;
stringReturns only the directory name from docname, which is
expressed as file://URL. For example,
Files.getDirectory("file://work/logo.png")
"file:///work".
returns
stringReturns the filename extension, if any, of docname. For
example,
returns
Files.getExtension("birthday.png")
".png". If the filename has no extension, an empty
string is returned. A filename that is expressed as file://URL is
acceptable.
stringReturns just the filename from docname, which is expressed as
file://URL. For example,
Files.getFilename("file:///work/logo.png")
"logo.png".
returns
stringReturns the URL of the language directory associated with the
currently running language.
noneIf the last call to a method in a Files object resulted in an error,
returns a string that describes the error. If the last call
succeeded, returns
null.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
MethodData typeNotes
19
getTempFilePath ({dirname})
isDirectory(dirname)
makePathFromDirAndFile(dirna
me, plainFilename)
open(docname, encoding,
bWrite)
rename(docname,
newPlainFilename)
stringThe argument, if used, must be expressed as file://URL. Returns
stringThe argument must be expressed as file://URL. Returns true if
string, stringThe first argument must be expressed as file://URL.
string, string, BooleanThe first argument must be expressed as file://URL. Opens the
string, stringThe docname argument is a file path or a file URL to the file that
a file URL in the Temporary Files directory or in the specified
directory. This method does not create a file; it simply returns a
unique file URL that does not conflict with existing files in the
directory. If
returned indicates a file in the specified directory rather than in
the Temporary Files directory.
the specified URL refers to a directory that exists;
otherwise.
Concatenates the two arguments to return a file URL that
references the specified filename in the specified directory. For
example,
specified file for reading or writing. The second argument
specifies the encoding. If the third argument is
opens for writing; otherwise it opens for reading. If the file
cannot be opened, returns
Reference object.
you want to rename.
The newPlainFilename argument is the new name to assign
to the file.
The rename method returns a URL path of the newly renamed
file if successful; otherwise Fireworks returns
dirname is passed and is not null, the URL that is
false
returns
true, the file
null; otherwise, returns a File
null.
setFilename(docname,
newPlainFilename)
swap(docname1, docname2)
string, stringThe first argument must be expressed as file://URL. Returns a
file URL with
example,
Files.setFilename("file:///work/logo.png",
"oldlogo.png")
"file:///work/oldlogo.png". This method does not
affect the file on disk; it simply provides a convenient way to
manipulate file URLs. To change the name on disk, use
rename().
string, stringEach argument must be expressed as a file://URL. Swaps the
contents of the two specified files, so that each file contains the
contents of the other file. Only files (not directories) can be
swapped, and both files must reside on the same drive. Returns
true if the swap is successful; false otherwise.
docname replaced by newPlainFilename. For
returns
File Reference object
The File Reference object is used to refer to a specific open file. The following table lists the methods of the File
Reference object, along with their data types and, where appropriate, acceptable values and notes.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
MethodData TypeNotes
20
close()
readline()
readLineUTF8
write(textString)
writeUTF8(textString)
noneCloses the current File Reference object. You are not required
noneReads the next line from the current File Reference object and
stringReads one line from the file that has been opened with UTF8
stringWrites the specified string to the current File Reference object.
stringWrites text in UTF8 encoding when the file is opened in UTF8
to use this method (the file is closed when the Files object is
destroyed), but it is useful for controlling access to a file.
returns it as a string. The end-of-line character(s) are not
included in the string. Returns
if the line is longer than 2048 characters.
encoding.
No end-of-line characters are appended; to include one, use
"\n".
encoding.
null if end-of-file is reached or
Find object
There are several ways to specify a Find object, depending on what you want to find and replace. Use the whatToFind
property to specify the type of find operation, along with the properties that are associated with each legal value for
whatToFind. These properties are listed in the following tables. Read-only properties are marked with a bullet (•).
Finding and replacing text
PropertyData typeNotes
whatToFindstringIn the format: "text"
findstringText to find.
matchCaseBooleanIf set to true, the search is case-sensitive. Defaults to false.
numItemsReplaced •IntegerNumber of replacements done in a file using Find and Replace.
regExpBooleanIf set to true, the find and replace text is interpreted as a
replacestringText to use as replacement text.
wholeWordBooleanIf set to true, only whole words matching the search text are
regular expression. The default is
found. The default is
false.
false.
Finding and replacing fonts and styles
PropertyData typeNotes
whatToFindstringIn the format: "font"
findstringName of font to find.
replacestringName of font to use as replacement.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
PropertyData typeNotes
findStyleintegerNumber that represents the style to find:
AnyStyle = -1
Plain = 0
Bold = 1
Italic = 2
BoldItalic = 3
Underline = 4
BoldUnderline = 5
ItalicUnderline = 6
BoldItalicUnderline = 7
replaceStyleintegerNumber that represents the style to be used as replacement.
findMinSizeinteger0 to 9999
findMaxSizeinteger0 to 9999
replaceSizeinteger0 to 9999, or pass -1 to leave size as is
21
Finding and replacing colors, fills, strokes, and effects
PropertyData typeNotes
whatToFindstringIn the format: "color"
findstringA color string that specifies the color to find (for more
information, see
replacestringA color string that specifies the color to use as a replacement
(for more information, see
fillsBooleanIf set to true, fills that match the specified colors are replaced.
strokesBooleanIf set to true, strokes that match the specified colors are
“Color string data type” on page 8).
“Color string data type” on page 8).
replaced.
effectsBooleanIf set to true, effects that match the specified colors are
replaced.
Finding and replacing URLs
PropertyData typesNotes
whatToFindstringIn the format: "url"
findstringURL to find, which is expressed as file://URL.
replacestringURL to use as replacement text, which is expressed as file://URL.
wholeWordBooleanIf set to true, only whole words that match the search text are
found. The default is
false.
matchCaseBooleanIf set to true, the search is case sensitive. Defaults to false.
regExpBooleanIf set to true, the find and replace text is interpreted as a
regular expression. The default value is
false.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
Finding and replacing non-websafe colors with the closest websafe color
PropertyData typeNotes
whatToFindstringIn the format: "nonwebcolor"
22
effectsBooleanIf set to true, colors in effects are replaced. The default value is
fillsBooleanIf set to true, colors in fills are replaced. The default value is
strokesBooleanIf set to true, colors in strokes are replaced. The default value
false.
false.
false.
is
System object
The following table lists the properties of the System object, along with their data types and, where appropriate,
acceptable values and notes. All System properties are read-only.
Property (read-only)Data typeNotes
osNamestringReturns the name of the operating system under which
controlFaceColorstringReturns the system color used for the control and panel faces
controlHilightColorstringReturns the system color used for control highlights (Windows-
controlShadowColorstringReturns the system color used for control shadows (Windows-
controlDarkShadowColorstringReturns the system color used for control dark shadows
Fireworks is running.
(Windows®-only property).
only property).
only property).
(Windows-only property).
hilightItemColorstringReturns the system color used for highlighting selections
hilightTextColorstringReturns the system color used for highlighting selected text
textColorstringReturns the system color used for text (Windows-only
menuColorstringReturns the system color used for menu backgrounds
menuTextColorstringReturns the system color used for text in menus (Windows-only
siteRootPath Path to the site root folder in which the file that need to be previewed reside.
Returns
0 if the operation succeeded.
Description
Calls the ADL tool to preview an HTML document as an Adobe AIR application. The path to file that needs to be
previewed is not specified because it is included in the application descriptor; this path is relative to the site root.
AIRext.PackageApplication()
Availability
Fireworks 10.
23
Usage
status = AIRext.PackageApplication(siteFullPath, packagePath, fileList);
Arguments
siteFullPath Path to the site root folder in which all files that needs to be included in package reside.
packagePath Full path of the resulting Adobe AIR package.
fileList Array of paths to files and folders that need to be included in package; all paths need to be relative to the
site root.
Returns
0 if the operation succeeded; 1 if an error occurred; 2 if the ADT tool generated an error (this error is saved into an
error log file).
Description
Calls the ADT tool package an Adobe AIR application.
AIRext.CreatePackage()
Availability
Fireworks 10.
Usage
status = AIRext.CreatePackage(siteFullPath, packagePath, fileList, appXMLPath,
certificatePath, password);
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
Arguments
siteFullPath Path to the site root folder in which all files that needs to be included in package reside.
packagePath Full path of the resulting Adobe AIR package.
fileList Array of paths to files and folders that need to be included in package; all paths need to be relative to the
site root.
appXMLPath Path to the application descriptor (if blank or missing, defaults to application.xml in site root).
certificatePath Path to the digital certificate with which to sign the package (if blank or missing, an unsigned AIRI
file will be created instead of a signed AIR file)
password Password for the specified certificate (if blank or missing, user will be prompted for the password).
Returns
0 if the operation succeeded.
Description
Calls the ADT tool to create a signed AIR package.
AIRext.CheckCertificatePassword()
24
Availability
Fireworks 10.
Usage
status = AIRext.CheckCertificatePassword(certificatePath, password);
Arguments
certificatePath Path to the digital certificate with which to sign the package.
password Password for the specified certificate.
Returns
Exitcode from ADT; 0 if OK, 7 if could not access certificate, and so on.
Description
Calls the ADT tool to check a certificate password.
certificatePath Path to the digital certificate whose password is being saved.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
password Password for the specified certificate.
Returns
0 if saved successfully.
Description
Saves the password for the given digital certificate, for the current session of Fireworks (no persistent storage).
AIRext.GetDigSigPassword()
Availability
Fireworks 10.
Usage
configurationPath = AIRext.GetDigSigPassword();
Arguments
None.
25
Returns
The previously saved password for the given digital certificate, or an empty string.
Description
Returns the name of the generated password file.
AIRext.GetLastErrorLogName()
Availability
Fireworks 10.
Usage
errLogName = AIRext.GetLastErrorLogName();
Arguments
None.
Returns
The name of the error log file if it was created, or an empty string.
Description
Returns the name of the generated error log file if one was created.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
AIRext.GetAIRInstallPath()
Availability
Fireworks 10.
Usage
configurationPath = AIRext.GetAIRInstallPath();
Arguments
None.
Returns
The full system path to the current user configuration folder (for example, "C:\Documents and
settings\...\Configuration").
Description
Returns the full system path name and path of the generated file.
26
AIRext.GetJREVersion()
Availability
Fireworks 10.
Usage
jreVersObj = AIRext.GetJREVersion();
Arguments
None.
Returns
An object with two properties - maxVersion and minVersion; if an error occurs the values of the maxVersion and
minVersion will be -1.
Description
Get the minimum and maximum versions of the JRE.
AIRext.CreateCertificate()
Availability
Fireworks 10.
Usage
status = AIRext.CreateCertificate(certificatePath, password, keyType, publisher, orgName,
orgUnit, country);
Last updated 5/17/2012
EXTENDING FIREWORKS
The Fireworks Object Model
Arguments
certificatePath Path to digital certificate file that will be created (required).
password Password for the created certificate (required)
keyType Encryption key type (either "1024-RSA" or "2048-RSA" (required).
publisher Name of publisher (required).
orgName Name of organization (optional).
orgUnit Organizational unit (optional).
country 2-letter code for country (optional, and length is not enforced).
Returns
0 if operation succeeded.
Description
Calls the ADT to create a self-signed digital certificate.
27
Last updated 5/17/2012
Chapter 3: The Document object
This chapter describes the Fireworks Document object and functions.
Document object properties
The following table lists the properties of the Document object, along with their data types, acceptable values, and
notes. Read-only properties are marked with a bullet (•). You can also use many API calls to work with documents.
For more information, see
PropertyData typeNotes
“Property inspector functions” on page 321.
28
backgroundColor
backgroundURL
brushes •
currentFrameNum
currentLayerNum
defaultAltText
docTitleWithoutExtension
exportFormatOptions
exportOptions
exportSettings
filePathForRevert
stringA color string that specifies the document canvas color (for
more information, see
stringSets a general URL for a document that uses a hotspot.
Everything that is not covered by the hotspot has the
background URL.
arrayArray of Brush objects that are available for use in the
document (for more information, see
page 243).
zero-based indexThe index of the current frame.
zero-based indexThe index of the current layer.
stringDefault Alt text for the output images. It works for single and
sliced images. Sliced images get the default, unless specific text
is specified for a slice. Corresponds to the text that is specified
in the Document-Specific tab of the HTML Setup dialog box.
stringThe title of the document file, without any file extension. If the
document has not been saved, this string is empty.
objectIdentical to exportOptions. Included for backward
compatibility with Fireworks 2.
objectExportOptions object (for more information, see
“ExportOptions object” on page 260).
objectExportSettings object (for more information, see
“ExportSettings object” on page 263).
stringThe path to the file from which this document was opened,
which is expressed as file://URL, or
“Color string data type” on page 8).
“Brush object” on
null if created from scratch.
filePathForSave
fills •
frameCount
frameLoopingCount
stringThe location to which this document was saved, which is
expressed as file://URL, or
arrayArray of Fill objects that are available for use in the document
(for more information, see
integerThe number of frames in the current document.
integer–1 — don’t repeat
0 — repeat forever
> 0 — repeat this number of times
null if never saved.
“Fill object” on page 265).
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
PropertyData typeNotes
29
frames •
gammaPreview
gradients •
gridColor
gridOrigin
gridSize
guides •
height
isDirty
isPaintMode •
arrayArray of Frame objects in the document (for more information,
“Frame object” on page 266).
see
BooleanIf set to true, the document should be previewed in opposite-
platform gamma. If set to
false, the document colors are
unadjusted.
arrayArray of Gradient objects that are available for use in the
document (for more information, see
“Gradient object” on
page 267).
stringA color string that specifies the color of the grid display (for
more information, see
“Color string data type” on page 8).
pointUsed to set the origin of the grid. Corresponds to the point set
when dragging the ruler origin from the upper-left of the
document when rulers are visible.
pointgridSize.x is the horizontal grid size; gridSize.y is the
vertical grid size.
objectGuides object (for more information, see “Guides object” on
page 267).
integerTotal height of the document, in pixels. To find the bottom
edge of the document, use
document.height.
document.top +
BooleanSet to true if the document was modified since the last time it
was saved.
BooleanSet to true if the document is currently in paint-mode editing,
false otherwise.
isSymbolDocument •
isValid
lastExportDirectory
lastExportFile
layers •
left
BooleanSet to true if the document is a Symbol or Button document,
false if it is an ordinary document. You might see this when
looking through the list of open documents and one is a
symbol-editing window.
BooleanSet to true if the document is open in Fireworks; false
otherwise. (Occasionally the JavaScript object that is
associated with a document lingers after the document closes;
this property lets you check for that eventuality.)
stringThe path to the last directory to which the file was exported,
which is expressed as file://URL, or
null if the file was never
exported. For instance, if the document was last exported to
file:///files/current/logo.gif", it returns
“
"file:///files/current".
stringThe name that was used the last time the file was exported, or
null if the file was never exported. For instance, if the
document was last exported to
"file:///files/current/logo.gif", it returns
"logo.gif".
arrayAn array of Layer objects in the document (for more
information, see
“Layer object” on page 268).
integerCoordinate of the left edge of the document, in pixels. To find
the right edge of the document, use
document.width.
document.left +
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
PropertyData typeNotes
30
mapType
matteColor
onionSkinAfter
onionSkinBefore
pagesCount •
pageName
patterns •
pathAttributes
pngText
stringAcceptable values are "client", "server", and "both".
Corresponds to the image-map type selected in File > HTML
Setup.
stringA color string that corresponds to the matte color specified in
the Optimize panel (for more information, see
“Color string
data type” on page 8). This string is used by the
useMatteColor property.
integerThe number of frames after the current frame to show through
onion skinning. Corresponds to the onion-skin controls in the
left edge of the Frames panel. A value of
skinning; a very large value (such as
0 indicates no onion
99,999) indicates onion
skinning of all frames after the current frame.
integerSimilar to the onionSkinAfter property, but refers to the
number of frames to show through onion skinning before the
current frame.
integerReturns the number of pages in the current document.
stringReturns the page name of the current page.
objectThe list of internal pattern names.
objectThe PathAttrs object (for more information, see “PathAttrs
object” on page 268). This object specifies default attributes
that will be applied to all newly created objects.
objectA structure that can be used to store various chunks of text in a
well-known format. For more information, see
“The pngText
property” on page 31.
resolution
resolutionUnits
savedSelections
textures
top
useMatteColor
width
currentPageNum
topLayers
floatDocument resolution, in pixels per unit (for more information,
resolutionUnits). The range is 1 to 5000.
see
stringUnits to be used with the resolution property. Acceptable
values are
"inch" and "cm".
objectArray of the saved bitmap selections in the active document.
arrayArray of Texture objects that are available for use in the
document (for more information, see
“Texture object” on
page 259).
integerCoordinate of the top edge of the document, in pixels. To find
the bottom edge of the document, use
document.height.
document.top +
BooleanIf set to true, the matteColor property is used when
exporting documents with transparent backgrounds. If set to
false, the matteColor property is ignored in this situation,
and the exported file is matted against the document’s canvas
color.
integerThe width of the document, in pixels. To find the right edge of
the document, use
document.left + document.width.
integerThe index of the current page.
arrayArray of top level layers within the document objects.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
The pngText property
Fireworks maintains the following fields for use with the pngText property:
Field nameValue
CreationTimeThe date and time the document was created.
31
SoftwareThe software used to create the document. The current version of Fireworks always sets this value to
“Adobe Fireworks CS5.”
You can edit these fields or add your own fields, and they will be preserved across file saves.
The pngText object corresponds directly to the 'tEXt' chunk of the document’s PNG structure.
Document functions
As discussed in an earlier section, you get and set document properties by calling functions as methods of the
document’s Document Object Model (DOM) (see
operate on a document’s DOM are listed in this section as dom.functionName(). However, you cannot simply type
dom.functionName(). In place of dom, you must type fw.getDocumentDOM() or fw.documents[documentIndex].
For example:
• How a function looks in this manual: dom.addNewHotspot()
• How you must type it:
fw.getDocumentDOM().addNewHotspot(); // operates on active document
or
fw.documents[documentIndex].addNewHotspot(); // operates on specified document
“Accessing a Fireworks document” on page 7). Methods that
dom.addBehavior()
Availability
Fireworks 3.
Usage
dom.addBehavior(action, event, eventIndex)
Arguments
action A string that specifies the behavior to be added, such as "MM_swapImageRestore()". For a list of all the
behaviors that can be added, see
event The event that triggers the behavior. Acceptable values are "onMouseOver", "onMouseOut", "onLoad", and
"onClick".
eventIndex An integer value that specifies the location where the behavior should be added, starting with 0
(although, to specify the end location, pass –
Returns
Nothing.
“Using the dom.addBehavior() function” on page 32.
1 here).
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Description
Adds a specified behavior to the selected hotspots and slices.
Example
The following command adds a simple rollover behavior at the end of the selected slice or hotspot:
The first argument is a string that specifies the behavior to be added; see dom.addBehavior(). The information in this
section describes the acceptable values for the action argument that is passed to dom.addBehavior().
mode Acceptable values for mode are “reveal all", "hide all", "reveal selection", and"hide selection".
If the user is not in bitmap mode, or if there is no pixel selection,
"reveal selection" and "hide selection"
operate the same as "reveal all" and "hide all", respectively.
bEnterMaskEditMode If bEnterMaskEditMode (optional) is set to true, Fireworks enters mask-edit mode on the
newly added mask; if omitted, it defaults to
false.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Returns
Nothing.
Description
Adds a new empty mask to the selected element. If the selection already has an element mask, it is replaced with the
new one. Only one element can be selected when calling this function. If selecting more than one element (or none) at
the time this function is called, Fireworks throws an exception.
position A floating-point value that specifies the x or y coordinate at which to add the guide.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
guidekind Acceptable values for guidekind are "horizontal" and "vertical". If guidekind is "horizontal", it
is assumed that
position is a y coordinate; if "vertical", it is an x coordinate.
Returns
Nothing.
Description
Adds a guide to the document. If a guide already exists at the specified position, this function has no effect.
Example
The following command adds a vertical guide at the x coordinate of 217:
fw.getDocumentDOM().addGuide(217, "vertical");
dom.addMasterPageLayer()
Availability
Fireworks CS3.
37
Usage
dom.addMasterPageLayer()
Arguments
To add a master page layer, the document must already have a master page in it. Include the level where the master
page layer should be inserted. For example:
fw.getDocumentDOM().addMasterPageLayer(-1)
Returns
Nothing.
Description
Adds a master page layer to the bottom of the layer hierarchy for the current page.
boundRectangle A rectangle that specifies the bounds of the image to be added (see “Rectangle data type” on
page 9). You cannot create an image that is larger than the document; therefore, if you pass in a rectangle with bounds
larger than the document size, you can create an image that is constrained to the document size.
bEnterPaintMode If bEnterPaintMode is true, the application immediately enters bitmap mode for the new image.
Returns
Nothing.
Description
Adds a new empty (transparent) image to the document.
Example
The following command adds an empty image that is 500 by 500 pixels in size, and then enters bitmap mode:
Adds a new image to the document containing the contents of the current paint-mode selection. The new image is
placed directly above the active bitmap. You must have a current pixel selection for this to succeed. The new bitmap
appears with Fireworks in paint mode.
dom.addNewImageViaCut()
Availability
Fireworks MX.
Usage
dom.addNewImageViaCut()
Arguments
None.
39
Returns
Nothing.
Description
Adds a new image to the document that contains the contents of the current paint mode selection. The new image is
placed directly above the active bitmap. You must have a current pixel selection for this to succeed. The selection is cut
from the previously active bitmap. The new bitmap appears with Fireworks in paint mode.
dom.addNewLayer()
Availability
Fireworks 3.
Usage
dom.addNewLayer(name, bshared)
Arguments
name A string that specifies the name for the new layer. If name is null, a new layer name is generated.
bShared A Boolean value that specifies whether the new layer is shared.
Returns
A string value that contains the name of the new layer.
Description
Adds a new layer to the document and makes it the current layer.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Example
The following command adds a new unshared layer with a default name that is generated by Fireworks:
fw.getDocumentDOM().addNewLayer(null, false);
dom.addNewLine()
Availability
Fireworks 3.
Usage
dom.addNewLine(startPoint, endPoint)
Arguments
startPoint and endPoint Points that specify the x,y coordinates between which the path is added (see “Point data
type” on page 9).
Returns
Nothing.
40
Description
Adds a new path between two points. The new path uses the document’s current default path attributes and is added
to the current frame and layer.
Example
The following command adds a new line between the specified coordinates:
boundingRectangle A rectangle that specifies the bounds of the oval to be added (see “Rectangle data type” on
page 9).
Returns
Nothing.
Description
Adds a new oval fitting into the specified bounding rectangle. The oval uses the document’s current default path
attributes and is added on the current frame and layer.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Example
The following command adds a new oval within the specified coordinates:
boundingRectangle A rectangle that specifies the bounds within which the new rectangle is added (see “Rectangle
data type” on page 9).
roundness A floating-point value between 0 and 1 that specifies the roundness to use for the corners (0 is no
roundness, 1 is 100% roundness).
Returns
Nothing.
Description
Adds a new rectangle or rounded rectangle fitting into the specified bounds. The rectangle uses the document’s current
default path attributes and is added on the current frame and layer.
Example
The following command adds a new rectangle with no round corners within the specified coordinates:
boundingRectangle A rectangle that specifies the bounds within which the new rectangle primitive is added (see
“Rectangle data type” on page 9).
roundness A floating-point value between 0 and 1 that specifies the “roundness” to use for the corners (0 is no
roundness, and 1 is 100% roundness).
Returns
Nothing.
42
Description
Adds a new rectangle primitive that fits in the specified bounds. The rectangle primitive uses the document’s current
default path attributes, is added on the current frame and layer, and has several editable properties, such as corner
roundness and transformation. The difference between a rectangle and a rectangle primitive is that a rectangle is a path
that is shaped like a rectangle, and a rectangle primitive preserves its rectangular quality; that is, if you drag a corner,
it remains a rectangle rather than becoming a quadrilateral.
Example
The following command adds a new rectangle primitive with no round corners within the specified coordinates:
controlPointFirst, mainpoint, and controlPointLast Points that specify the x,y coordinates of the preceding
control point, the main point, and the following control point of the Bezier path (see
bCopyAttrs If bCopyAttrs is false, the path’s stroke and fill are copied directly from the document’s current stroke
“Point data type” on page 9).
and fill settings. If it is true, the path’s fill is set to None, and the brush is set to something other than None.
Returns
Nothing.
Description
Adds a new path that consists of a single Bezier point. The path uses the default fill, stroke, and so on, and is added on
the current frame and layer. The point is selected after it is added.
Example
The following command adds a new path that consists of a single Bezier point at the specified coordinates and copies
the path’s stroke and fill from the document’s current stroke and fill settings:
sizeInBytes An integer that specifies the size to be used for exporting. It is used as described in the following list:
• If a document has no slices, sizeInBytes adjusts the export settings for the current frame so that the image is less
than or equal to
• If a document has slices, sizeInBytes adjusts the size of all exported images so that the sum of the sizes is greater
than or equal to
bOkToIncreaseSize Specifies whether the export file size can be increased.
sizeInBytes.
sizeInBytes.
46
• If bOkToIncreaseSize is true, and the current size is less than sizeInBytes, the argument increases the quality
of the export settings as much as possible, making the export size larger if necessary.
• If bOkToIncreaseSize is false, the argument increases the quality of the export settings as much as possible
without increasing the export size.
Description
Adjusts the export settings as specified.
dom.adjustFontSize()
Availability
Fireworks MX.
Usage
dom.adjustFontSize(amount)
Arguments
amount The amount, specified in points, by which to change the font size. Positive values (such as "2pt") increase the
size, while negative values (such as
Returns
Nothing.
"-1pt") decrease the size.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Description
Increases (positive values) or decreases (negative values) the font size of selected text elements. If a text element has
multiple font sizes, each size is adjusted independently.
dom.align()
Availability
Fireworks 3. Align to canvas parameter is only available in Fireworks 8.
Usage
dom.align(alignmode, alignToCanvas)
Arguments
alignmode Acceptable values are "left", "right", "top", "bottom", "center vertical", and "center
horizontal".
alignToCanvas Boolean. Determines if the alignment is to the canvas or items. The default value is false.
Returns
Nothing.
47
Description
Aligns the selection.
dom.appendPointToHotspot()
Availability
Fireworks 3.
Usage
dom.appendPointToHotspot(pt, tolerance)
Arguments
pt A point that specifies the x,y coordinates of the point to be added (see “Point data type” on page 9).
tolerance A floating-point value > = 0 that specifies the tolerance between the new point and the starting point of
the polyline path. If the new point is within
Returns
Nothing.
Description
Appends a point to the selected unclosed polygon hotspot. If an unclosed polygon hotspot is not selected, a new
polygon hotspot is created with the single point that passed in.
tolerance of the starting point, the polyline path is closed.
contourIndex An zero-based index value that specifies the contour to which the Bezier point is appended. For paths
with multiple contours, the contours are in an arbitrary order.
ptToInsertBefore A zero-based index value that specifies where on the path the new point should be placed. The
new point is appended in front of the point that this integer represents. To add a point to the beginning of the path,
0; to add a point to the end of the path, pass a large number.
pass
controlPointFirst, mainPoint, and controlPointLast Points that specify the x,y coordinates of the preceding
control point, the main point, and the following control point of the new point (see
“Point data type” on page 9).
48
Returns
Nothing.
Description
Appends a Bézier point to the selected path.
See also
dom.insertPointInPath()
dom.appendPointToSlice()
Availability
Fireworks 3.
Usage
dom.appendPointToSlice(pt, tolerance)
Arguments
pt A point that specifies the x,y coordinates of the point to be added (see “Point data type” on page 9).
tolerance A floating-point value > = 0 that specifies the tolerance between the new point and the starting point of
the polyline path. If the new point is within
tolerance of the starting point, the polyline path is closed.
Returns
Nothing.
Description
Appends a point to the selected unclosed polygon slice. If an unclosed polygon slice is not selected, then a new polygon
slice is created with the single point that passed in.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
dom.applyCharacterMarkup()
Availability
Fireworks 3, updated in Fireworks 4.
Usage
dom.applyCharacterMarkup(tag)
Arguments
tag Acceptable values for tag are "b", "i", and "u", for bold, italic, and underline: and "fwplain", which was added
in Fireworks 4, for text with no character markup.
Returns
Nothing.
Description
Applies the specified character markup to the selected text.
49
dom.applyCurrentFill()
Availability
Fireworks 3.
Usage
dom.applyCurrentFill(NoNullFills)
Arguments
bNoNullFills If bNoNullFills is true and the current fill is None, then a default fill is applied instead of no fill.
Returns
Nothing.
Description
Applies the document’s current fill to the selection.
Example
The following command applies the current fill to the selection:
fw.getDocumentDOM().applyCurrentFill(true);
dom.applyEffects()
Availability
Fireworks 3.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Usage
dom.ApplyEffects(effectList)
Arguments
effectList An EffectList object (see “EffectList object” on page 254). If effectList is null, this function removes
all effects from the selection.
Returns
Nothing.
Description
Applies the specified effects to the selection.
Example
The following command applies a drop shadow with an angle of 315, a blur of 4, a color of black, and a distance of 7
currentPosition A floating-point value that specifies the current position of the slice guide to be moved.
newPosition A floating-point value that specifies the new position of the slice guide.
guidekind Acceptable values are "horizontal" and "vertical". If the value of guidekind is “horizontal” ,
Fireworks assumes that the specified positions are y coordinates; if
"vertical", the specified positions are x
coordinates.
isMagneticDrag A Boolean value that determines whether to move other slice guides between the old and new
positions. If
isMagneticDrag is true, Fireworks also moves slice guides between the old guide position and the new
position. This action resizes and possibly deletes rectangular slices that do not abut the slice guide at
currentPosition.
isSingleDrag A Boolean value that determines whether the operation is performed only on the selected slice or on
all slices that are affected by the slice guide. If
changeSliceGuide() action on the selected slice.
isSingleDrag is true, Fireworks performs only the
Returns
Nothing.
55
Description
Moves a slice guide’s position to a new location, which resizes any rectangular slices that abut the guide. An argument
controls whether slice guides that exist between the old position and the new one are also moved.
If a slice is resized so that it has zero width or height, the slice is deleted.
This function does not change slices that are not rectangular.
Example
The following command moves a vertical slice guide from position 135 to position 275, and moves all vertical slice
guides between 135 and 275 to 275:
whatIfResolutionDifferent An optional string that specifies how resampling should be done if the resolution of
the clipboard contents doesn’t match the resolution of the document. Acceptable values for
whatIfResolutionDifferent are "resample", "do not resample", and "ask user" (displays a dialog box to let
the user decide). If
whatIfPastingIntoElementMask An optional argument, added in Fireworks 4, that applies only if the user is
whatIfResolutionDifferent is omitted or null, "ask user" is assumed.
editing an element mask, and that element mask is an empty image mask. In this case, the pasted elements replace the
existing mask (because it is essentially a mask that doesn’t mask anything). If the image mask isn’t empty, the pasted
elements are added to the existing mask, rather than replacing it. Acceptable values for
whatIfPastingIntoElementMask are "image", "vector", and "ask user". If
whatIfPastingIntoElementMask is omitted or null, "ask user" is assumed.
Returns
Nothing.
Description
Pastes the clipboard contents into the document.
Example
The following command pastes the clipboard contents into the document. If there is a need for resampling, Fireworks
asks the user to decide how to resample.
whatIfResolutionDifferent A string that specifies how resampling should be done if the resolution of the
clipboard contents doesn’t match the resolution of the document. Acceptable values for
whatIfResolutionDifferent are "resample", "do not resample", and "ask user" (displays a dialog box to let
the user decide). If
masktype Specifies how to paste the mask. Acceptable values are “image“ (always paste as an image mask), “vector“
(always paste as a vector mask), and “
single image, it is pasted as an image mask, even if you pass “
maskReplaceOptions Acceptable values for maskReplaceOptions are “replace“ (if an element mask already exists,
replace it with the pasted one), “
whatIfResolutionDifferent is omitted or null, "ask user" is assumed.
ask“ (displays a dialog box to let the user decide). If the clipboard contains a
vector“.
add“ (if an element mask already exists, add the pasted mask to it), and “ask“ (displays
a dialog box to let the user decide).
Returns
Nothing.
Description
Pastes the clipboard contents into the document as an element mask. Only one element can be selected when calling
this function. If more than one element (or none) is selected when this function is called, Fireworks throws an
exception. An exception is also thrown if there is nothing on the clipboard.
59
dom.clipPasteAttributes()
Availability
Fireworks 3.
Usage
dom.clipPasteAttributes()
Arguments
None.
Returns
Nothing.
Description
Pastes the attributes from the clipboard onto the selection.
Example
The following command applies the attributes that were copied to the clipboard onto the selected items:
fromChannel If the current selection is not a single bitmap, a new opaque bitmap is created and the fromChannel is
pasted in to all three color channels of the new bitmap, resulting in a grayscale image. This first argument is ignored if
the current selection is not a single bitmap.
toChannel If the currently selected element is a bitmap, the toChannel argument is used to specify where to paste
the color data.
Returns
Nothing.
60
Description
Pastes the specified color channel on the clipboard into each of the RGB channels of a new image or into the specified
channel of the selected image, if any.
Example
The following command copies the red data from the clipboard into the red channel:
Fireworks 3, deprecated in 4 in favor of dom.clipPasteAsMask() (see dom.clipPasteAsMask()).
Usage
dom.clipPasteInside({whatIfResolutionDifferent})
Arguments
whatIfResolutionDifferent An optional string that specifies how resampling should be done if the resolution of
the clipboard contents doesn’t match the resolution of the document. Acceptable values for
whatIfResolutionDifferent are "resample", "do not resample", and "ask user" (displays a dialog box to let
the user decide). If
whatIfResolutionDifferent is omitted or null, "ask user" is assumed.
Returns
Nothing.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Description
Pastes the clipboard contents into the selection, and places the selected element into the element mask for the pasted
elements. If the selected element already has a mask, this function groups the pasted elements with the selected element
and applies the existing element mask to the group.
Example
The following command pastes the clipboard contents inside the selected items. If the resolution of the clipboard
contents doesn’t match the resolution of the document, Fireworks resamples the clipboard contents to match the
document.
fw.getDocumentDOM().clipPasteInside("resample");
dom.cloneSelection()
Availability
Fireworks 3.
Usage
dom.cloneSelection()
61
Arguments
None.
Returns
Nothing.
Description
Makes exact duplicates of the selection, placing the duplicated items directly on top of the original items.
Example
The following command copies the selected items on top of the original items:
fw.getDocumentDOM().cloneSelection();
See also
dom.duplicateSelection()
dom.close()
Availability
Fireworks 3.
Usage
dom.close(bPromptToSaveChanges)
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Arguments
bPromptToSaveChanges If bPromptToSaveChanges is true, and the document was changed since the last time it
was saved, the user is prompted to save any changes to the document. If
bPromptToSaveChanges is false, the user is
not prompted, and changes to the document are discarded.
Returns
Nothing.
Description
Closes the document.
dom.convertAnimSymbolToGraphicSymbol()
Availability
Fireworks 4.
Usage
dom.converAnimSymbolToGraphicSymbol()
62
Arguments
None.
Returns
Nothing.
Description
If a single animation symbol is selected, this function converts it from an animation symbol to a graphics symbol.
See also
dom.convertToAnimSymbol(), dom.convertToSymbol()
dom.convertMarqueeToPath()
Availability
Fireworks 7.
Usage
dom.convertMarqueeToPath()
Arguments
None.
Returns
Nothing.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Description
Converts marquee selection to path.
dom.convertPathToMarquee()
Availability
Fireworks 7.
Usage
dom.convertPathToMarquee(mode, featherAmount)
Arguments
mode Sets the mode. Acceptable values are "hard edge", "antialias", and "feather".
featherAmount Sets the amount of feathering for the marquee selection. This value is ignored if mode is not set to
kernelWidth An integer that defines the width of the filter coefficients.
kernelHeight An integer that defines the height of the filter coefficients.
kernelValues An array of integers that defines the values for specific filter patterns.
affectsAlpha A Boolean value: true means the convolution filter affects the transparency of the bitmap; false
means that the bitmap transparency isn’t affected by the filter.
Returns
Nothing
Description
Applies convolution, or irregular, filters to the selected bitmap based on the pattern defined by the argument values.
Example
The following example applies an edge-detection filter to the bitmap:
// width of convolution kernel
var w = 3;
// height of convolution kernel
var h = 3;
// Edge detection kernel
var k = new Array(0, 1, 0, 1, -4, 1, 0, 1, 0);
boundingRectangle A rectangle that specifies the bounds within which the selection should be cropped (see
“Rectangle data type” on page 9).
Returns
Nothing.
67
Description
Crops the selection to the specified rectangle.
dom.deleteAllInDocument()
Availability
Fireworks MX.
Usage
dom.deleteAllInDocument()
Arguments
None.
Returns
Nothing.
Description
Deletes all of the objects in the document.
dom.deleteFrames()
Availability
Fireworks 3.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Usage
dom.deleteFrames(frameIndex, howMany)
Arguments
frameIndex An integer value that specifies the location at which to begin deleting frames, starting with 0 (although,
to specify the current frame, pass –1).
howMany Specifies how many frames to delete.
Returns
Nothing.
Description
Deletes one or more frames.
dom.deleteLayer()
Availability
Fireworks 3.
68
Usage
dom.deleteLayer(layerIndex)
Arguments
layerIndex An integer value that specifies the layer to be deleted, starting with 0 (although, to specify the current
layer, pass –
1 here).
Returns
Nothing.
Description
Deletes a layer.
Example
The following command deletes the current layer:
fw.getDocumentDOM().deleteLayer(-1);
dom.deletePageAt()
Availability
Fireworks CS3.
Usage
dom.deletePageAt(pageNum)
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Arguments
pageNum A long value that indicates the page number of the page to be deleted.
Returns
Nothing.
Description
Deletes a specified page from the current document. For example:
fw.getDocumentDOM().deletePageAt(0)
dom.deletePointOnPath()
Availability
Fireworks 4.
Usage
dom.deletePointOnPath(contourIndex, pointIndex)
69
Arguments
contourIndex An integer value that specifies the contour that contains the point to be deleted, starting with 0
(although, to specify the current contour, pass –
pointIndex An integer value that specifies the point to be deleted, starting with 0 (although, to specify the current
point, pass –
1 here).
1 here).
Returns
Nothing.
Description
Deletes the specified point on the currently selected path. If the point is the only one on its contour, the entire contour
is deleted. If the point is the only one in the path, the entire path is deleted. The specified point does not need to be
selected.
Example
The following command deletes the currently selected point:
fw.getDocumentDOM().deletePointOnPath(-1, -1);
dom.deleteSavedSelection()
Availability
Fireworks 3.
Usage
dom.deleteSavedSelection(selection)
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Arguments
selection The name of the saved bitmap selection.
Returns
Nothing.
Description
Deletes the selection or the pixel selection if Fireworks is in bitmap mode.
Example
If Fireworks is not in bitmap mode, the following command deletes the selected items. If Fireworks is in bitmap mode,
the following command fills the selected items to transparent.
fw.getDocumentDOM().deleteSavedSelection(false);
dom.deleteSelection()
Availability
Fireworks 3.
70
Usage
dom.deleteSelection(bFillDeletedArea)
Arguments
bFillDeletedArea This argument is ignored if Fireworks is not in bitmap mode. If Fireworks is in bitmap mode and
bFillDeletedArea is true, the deleted pixels are filled with the current fill color. If false, the deleted pixels are filled
to transparent.
Returns
Nothing.
Description
Deletes the selection, or the pixel selection if Fireworks is in bitmap mode.
Example
If Fireworks is not in bitmap mode, the following command deletes the selected items. If Fireworks is in bitmap mode,
the following command fills the selected items to transparent.
fw.getDocumentDOM().deleteSelection(false);
dom.deleteSymbol()
Availability
Fireworks 3.
Usage
dom.deleteSymbol(symbolName)
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Arguments
symbolName The name of the symbol to delete from the library. If more than one symbol exists with this name, only
the first symbol is deleted.
• To delete all the selected symbols from the library (not document), pass null.
• If the deleted symbols contain any active instances in the document, the instances are also deleted.
Returns
Nothing.
Description
Deletes the specified symbols from the library.
Example
The following command deletes the selected symbols from the library as well as any active instances from the
document:
fw.getDocumentDOM().deleteSymbol(null);
71
dom.detachInstanceFromSymbol()
Availability
Fireworks 3.
Usage
dom.detachInstanceFromSymbol()
Arguments
None.
Description
Breaks the links between the selected instances and the owning symbols.
Returns
Nothing.
dom.detachTextFromPath()
Availability
Fireworks 3.
Usage
dom.detachTextFromPath()
Arguments
None.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Returns
Nothing.
Description
Splits the selected text-on-a-path items into its original text and path items.
dom.detachSharedLayer()
Availability
Fireworks CS3.
Usage
dom.detachSharedLayer(layerNum, pageNum)
Arguments
layerNum A long value that specifies the layer number for the layer that is to be detached.
pageNum A long value that specifies the page number of the page from which the layer will be detached.
72
Returns
Nothing.
Description
Detaches the specified shared layer from the specified page. You can only detach a parent layer, not a sub layer. When
the parent later is detached, the sub layers are automatically detached as well.
Example:
fw.getDocumentDOM().detachSharedLayer(1, 1)
dom.distribute()
Availability
Fireworks 3, updated with distributeToCanvas parameter in Fireworks 8.
Usage
dom.distribute(distmode, distributeToCanvas)
Arguments
distmode Acceptable values are "vertical" and "horizontal".
distributeToCanvas A Boolean value that determines whether items are distributed to the canvas. Default value is
"false".
Returns
Nothing.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Description
Distributes the selection along a vertical or horizontal dimension.
dom.distributeLayerToFrames()
Availability
Fireworks 3.
Usage
dom.distributeLayerToFrames(layerIndex)
Arguments
layerIndex An integer value that specifies the layer that contains the items to be distributed, starting with 0
(although, to specify the current layer, pass –1 here).
Returns
Nothing.
73
Description
Distributes the items on the specified layer to the frames of the document, adding frames if necessary. The first item
on the layer goes to the first frame, the second item to the second frame, and so on. New frames are added to the
document, if necessary. If there is only one item in the specified layer, this function has no effect.
dom.distributeSelectionToFrames()
Availability
Fireworks 3.
Usage
dom.distributeSelectionToFrames()
Arguments
None.
Returns
Nothing.
Description
Distributes the selected items to the frames of the document, adding frames if necessary. The first item goes to the
current frame, the second item to the next frame, and so on. If only one item is selected, this function has no effect.
frameIndexFirst and frameIndexLast Integer values that specify the range of frames (inclusive) to which the
items should be copied, starting with
• If both arguments are the same, duplicates are placed only on that frame.
• If the range includes the current frame, duplicates are not placed on that frame.
Returns
Nothing.
0 (although, to specify the current frame, pass –1 here).
Description
Duplicates the selection to a range of frames of the document.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
dom.duplicateSelectionToFrames()
Availability
Fireworks 3.
Usage
dom.cuplicateSelectionToFrames(whichFrames)
Arguments
whichFrames Acceptable values are "all", "previous", "next", and "end". Note that "end" means the last frame
of the document; it does not add a new frame.
Returns
Nothing.
Description
Duplicates the selection to specified frames of the document.
77
dom.duplicateSymbol()
Availability
Fireworks 3.
Usage
dom.duplicateSymbol(symbol)
Arguments
symbol The symbol to duplicate.
• To duplicate all selected symbols in the library (not the document), pass a null-value.
• Duplicating a linked symbol results in a nonlinked duplicate.
Returns
Nothing.
Description
Duplicates the specified symbol.
dom.duplicateSymbolForAlias()
Availability
Fireworks 3.
Usage
dom.duplicateSymbolForAlias()
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Arguments
None.
Returns
Nothing.
Description
If any symbol instances are selected, this function makes duplicate symbols of all the symbols that are pointed to by
those instances. The selected instances are updated to point to the new duplicate copies of the symbols. Duplicate
symbols always result in nonlinked duplicates. (The use of the word “alias” in the function name corresponds to an
“instance” in a Fireworks document.)
dom.elementsAt()
Availability
Fireworks MX 2004.
Usage
dom.elementsAt(where)
78
Arguments
where Specifies which rectangle to check for elements. To find the elements under a single point (similar to selecting
with the Subselection tool), set left equal to right and top equal to bottom. To find elements within a rectangle (similar
to drag-selecting with the Pointer tool), set the values to the desired rectangle.
Returns
An array of zero of more elements.
Description
Returns a list of zero or more elements at the given location. Similar to selecting with the Subselection tool or dragselecting with the Pointer tool.
dom.enableElementMask()
Availability
Fireworks 4, updated with new arguments in Fireworks MX.
enable A Boolean value that toggles the element mask between enabled (true) and disabled (false).
selectAndEnterPaintModeIfPossible A Boolean value that determines the mode for the mask. If
selectAndEnterPaintModeIfPossible is true, and the mask is a bitmap mask, then bitmap mode is entered for
the mask. It is
false by default.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
newSelectionMaskAn optional bitmap selection mask. If newSelectionMask is not null, and
selectAndEnterPaintModeIfPossible is true, the selection will be set on the mask after entering paint mode. This
argument is
null by default.
Returns
Nothing.
Description
Enables or disables the element mask on the selected element. If more than one element (or no elements) are selected
when this function is called, Fireworks throws an exception.
dom.enableNineScale()
Availability
Fireworks CS3
Usage
dom.enableNineScale(status)
79
Arguments
status A Boolean value that toggles 9-slice scaling between enabled and disabled.
Returns
Nothing.
Description
Enables or disables 9-slice scaling for the selected symbol.
Example
The following command enables 9-slice scaling for the selected symbol:
fw.getDocumentDOM().enableNineScale(true);
dom.enableTextAntiAliasing()
Availability
Fireworks MX.
Usage
dom.enableTextAntiAliasing(antiAlias)
Arguments
antiAlias A Boolean value to turn anti-aliasing on (true) or off (false).
Returns
Nothing.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Description
Turns anti-aliasing on or off for the selected blocks of text.
dom.enterPaintMode()
Availability
Fireworks 3, with the argument newSelectionMask added in Fireworks MX.
Usage
dom.enterPaintMode({newSelectionMask})
Arguments
newSelectionMask An optional bitmap selection mask. When newSelectionMask is not null, the selection is set
on the currently selected bitmap after entering paint mode. This argument is null by default.
Returns
Nothing.
80
Description
Enters image edit mode on the selected items. Has no effect if nothing is selected or if a non-image item is selected.
dom.exitPaintMode()
Availability
Fireworks 3.
Usage
dom.exitPaintMode()
Arguments
None.
Returns
Nothing.
Description
Leaves bitmap mode. Has no effect if Fireworks is not in bitmap mode.
dom.exitSymbolEdit()
Availability
Fireworks 9.
Usage
dom.exitSymbolEdit(level)
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Arguments
level Integer that specifies the number of levels back to exit symbol edit mode, especially when exiting Nested
Symbols.
Returns
Nothing.
Description
Exits the symbol edit mode through the number of levels specified.
dom.exportElements()
Availability
Fireworks 10.
Usage
dom.exportElements(elements, imagesUrl, name)
81
Arguments
elements An array that contains the objects to be exported.
imagesUrl Folder name to which the image is exported. Specified as file:///.
name Name of the image.
Returns
Nothing.
Description
Exports an array of elements on the canvas to a 32-bit PNG image, based on the image export settings.
dom.exportOptions.loadColorPalette()
Availability
Fireworks 3.
Usage
dom.exportOptions.loadColorPalette(fileURL)
Arguments
fileURL A string, which is expressed as a file://URL, that specifies the GIF or ACT file that is used to replace the color
panel.
Returns
true if the file is read successfully; false if the file is not the expected format or is not read successfully for any other
reason.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Description
Replaces the values in dom.exportOptions.paletteEntries with those in the specified GIF or ACT file. This
function also sets
dom.exportOptions.paletteMode to "custom". For more information, see “ExportOptions
object” on page 260.
dom.exportOptions.saveColorPalette()
Availability
Fireworks 3.
Usage
dom.exportOptions.saveColorPalette(fileURL)
Arguments
fileURL A string, which is expressed as a file://URL, that specifies the name of the file to which the color panel should
be saved. Do not specify a file extension; the .act extension is added automatically.
Returns
Nothing.
82
Description
Saves the values in dom.exportOptions.paletteEntries to the specified color panel (ACT file). This function does
not modify the document. For more information, see
“ExportOptions object” on page 260.
dom.exportTo()
Availability
Fireworks 3.
Usage
dom.exportTo(fileURL, {exportOptions})
Arguments
fileURL A string, which is expressed as a file://URL, that specifies the name of the exported file.
exportOptions An ExportOptions object (see “ExportOptions object” on page 260). This argument is optional. If
this argument is omitted or null, the document’s current Export Options settings are used. If values are passed in with
exportOptions, they are used for this export operation only; they do not change the document’s exportOptions
property.
Returns
true if the file is successfully exported; false otherwise.
clickPt A point that specifies the x,y coordinates of the pixel to be filled or generated (see “Point data type” on
page 9).
p1, p2, and p3 Points that specify the fill-vector. These arguments are ignored if the current fill does not use a fillvector.
bFillSelectionOnly If bFillSelectionOnly is true, the remaining arguments are ignored. If it is false, the
current pixel selection is ignored, and a new one is generated using the values passed for
featherAmt. (This behavior is the same as if the Magic Wand tool were used at the clickPt location.)
tolerance An integer between 0 and 255, inclusive, that specifies the tolerance for selecting pixels.
tolerance, edgemode, and
83
edgemode Acceptable values are "hard edge", "antialias", and "feather".
featherAmt An integer between 0 and 32,000, inclusive, that specifies the number of pixels to feather. This value is
ignored if the value of
edgemode is not "feather".
Returns
Nothing.
Description
When the selection is an image and Fireworks is in bitmap mode, this method fills the selected pixels with the current
fill or generates a new pixel selection.
Example
The following command fills the selection with a hard edge, and the tolerance set to 32:
LiveEffect An Effect object (see “Effect object” on page 248).
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Returns
Nothing.
Description
Applies the specified pixel filter to the selection. Items that are not images are converted into images before the filter
is applied. Only external filters that are capable of also being Live Effects can be applied using this function. To apply
other types of external filters, use
dom.filterSelectionByName().
Example
The following command runs the selected pixels through the hue/saturation filter and then sets hue to 30 and
saturation to 20:
ID The EffectMoaID of the filter you want applied.
Returns
Nothing.
Description
Applies the specified pixel filter to the selection as a permanent action, not as a Live Effect. (To apply filters that can
also be Live Effects, you can use
dom.filterSelection().) This function always displays a dialog box.
dom.filterSelectionByName()
Availability
Fireworks 3.
Usage
dom.filterSelectonByName(category, name)
Arguments
category A string that specifies the category of the pixel filter to be applied. Acceptable values depend on which filters
you have installed.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
name A string that specifies the name of the pixel filter to be applied. Acceptable values depend on which filters you
have installed.
Returns
Nothing.
Description
Applies the specified pixel filter to the selection as a permanent action, not as a Live Effect. (To apply filters that can
also be Live Effects, you can use dom.filterSelection().) This function always displays a dialog box.
dom.findNamedElements()
Availability
Fireworks 4.
Usage
dom.findNamedElements(name)
85
Arguments
name
A case-sensitive string that specifies the exact element name to find. To specify elements that have no name, pass
Returns
An array of elements that have the specified name, or null if no objects have the specified name.
Description
Looks for elements that have the specified name.
See also
dom.setElementName()
dom.flattenDocument()
Availability
Fireworks 3.
Usage
dom.flattenDocument()
Arguments
None.
null
.
Returns
Nothing.
Description
Flattens the entire document into a single pixel image. This is the same behavior as the Merge Layers command.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
dom.flattenSelection()
Availability
Fireworks 3.
Usage
dom.flattenSelection()
Arguments
None.
Returns
Nothing.
Description
Flattens the selection into a single pixel image. This action is the same behavior as the Merge Images command.
dom.getFontMarkup()
86
Availability
Fireworks 3.
Usage
dom.getFontMarkup(fontAttribute)
Arguments
fontAttribute Acceptable values for fontAttribute are "size", "color", and "face".
Returns
A string that specifies the markup value. Returns null if the text has multiple attributes or if the selection contains no
text.
Description
Gets a font markup attribute for the selected text.
dom.getLockGuides()
Availability
Fireworks 8.
Usage
dom.getLockGuides()
Arguments
None.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Returns
True if the guides are locked; false otherwise.
Description
Determines if the guides are locked.
dom.getPageSetter()
Availability
Fireworks 9.
Usage
dom.getPageSetter()
Arguments
None.
Returns
The PageSetter object which helps in changing pages without refreshing.
87
Description
Gets the pageSetter object of type SetCurrentPage, with the pageNum, which is a zero-based index of the current page.
dom.getParentLayerNum()
Availability
Fireworks CS3.
Usage
dom.getParentLayerNum(currentLayer)
Arguments
currentLayer A long value that specifies the index of the current layer.
Returns
The layer index number of the parent layer. If the specified layer is a top-level layer, it returns a value of -1.
Description
Gets the parent layer index number for the specified layer.
dom.getPixelMask()
Availability
Fireworks 3, deprecated in 4.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Usage
dom.getPixelMask()
Arguments
None.
Returns
The mask for the current pixel selection. Returns null if Fireworks is not in bitmap mode, or if there is no pixel
selection. For information on the format of mask variables, see
“Mask data type” on page 8.
Description
Gets the current pixel-selection mask. The result of this call could be used to call dom.enableElementMask() or
dom.enterPaintMode().
dom.getSelectionBounds()
Availability
Fireworks 3.
88
Usage
dom.getSelectionBounds()
Arguments
None.
Returns
A rectangle (see “Rectangle data type” on page 9). Returns null if nothing is selected.
Description
Gets the bounding rectangle of the selection.
dom.getShowGrid()
Availability
Fireworks 3.
Usage
dom.getShowGrid()
Arguments
None.
Returns
true if the grid is visible; false otherwise.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Description
Determines whether the grid is visible.
dom.getShowGuides()
Availability
Fireworks 8.
Usage
dom.getShowGuides()
Arguments
None.
Returns
true if the guides are visible; false otherwise.
Description
Determines if the guides are visible.
89
dom.getShowRulers()
Availability
Fireworks 3.
Usage
dom.getShowRulers()
Arguments
None.
Returns
true if the rulers are visible; false otherwise.
Description
Determines whether the rulers are visible.
dom.getSnapToGuides()
Availability
Fireworks 8.
Usage
dom.getSnapToGuides()
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Arguments
None.
Returns
true if the Snap to Guides function is available; false otherwise.
Description
Determines if the Snap to Guides function is available.
dom.getSnapToGrid()
Availability
Fireworks 3.
Usage
dom.getSnapToGrid()
Arguments
None.
90
Returns
true if the Snap to Grid function is active; false otherwise.
Description
Determines whether the Snap to Grid function is active.
dom.getTextAlignment()
Availability
Fireworks 3.
Usage
dom.getTextAlignment()
Arguments
None.
Returns
One of the following strings: "left", "center", "right", "justify", "stretch", "vertical left", "vertical
center", "vertical right", "vertical justify", or "vertical stretch". Returns null if the text has multiple
alignments or if the selection contains no text.
Description
Gets the alignment of selected text.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
dom.group()
Availability
Fireworks 3, argument deprecated in 4.
Usage
dom.group({type})
Arguments
type An optional string that specifies how to group the items. Acceptable values are "normal", "mask to image",
"mask to path". If the argument is omitted, "normal" is assumed. In Fireworks 4, "mask to image" and "mask
and
to path"
Returns
Nothing.
Description
Groups the selection. To ungroup elements use dom.ungroup() (see dom.ungroup()).
are deprecated.
91
Example
The following command sets the selected group to mask to the image:
replace with fw.getDocumentDOM().group("normal");
dom.hasCharacterMarkup()
Availability
Fireworks 3, updated in Fireworks 4.
Usage
dom.hasCharacterMarkup(tag)
Arguments
tag Acceptable values are "b", "i", and "u", for bold, italic, and underline; and "fwplain", which was added in
Fireworks 4, for text without character markup.
Returns
true if the text has the specified character markup; false if it does not or if only part of the text has the markup.
Description
Determines whether the selected text has the specified character markup.
dom.hasMasterPage()
Availability
Fireworks CS3.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
Usage
dom.hasMasterPage()
Arguments
None.
Returns
A Boolean value of true if the current document has a master page, or false if there is no master page.
Description
Indicates whether or not a master page exists for the specified document. For example:
fw.getDocumentDOM().hasMasterPage()
dom.hideSelection()
Availability
Fireworks 3.
92
Usage
dom.hideSelection()
Arguments
None.
Returns
Nothing.
Description
Hides the selection. To redisplay it, use dom.showAllHidden().
fileURL The filename of the file to be imported, which is expressed as a file://URL.
boundingRectangle A rectangle that specifies the size to make the imported file (see “Rectangle data type” on
page 9). If boundingRectangle is specified with left == right and top == bottom, the file is brought in unscaled
with its top-left corner at the specified location, and the third argument is ignored.
Last updated 5/17/2012
EXTENDING FIREWORKS
The Document object
bMaintainAspectRatioIf bMaintainAspectRatio is true, the file is scaled to the largest size that fits within
boundingRectangle while retaining the file’s current aspect ratio. (This is a handy option for creating thumbnails.)
false, the file is scaled to fill boundingRectangle.
If it is
Returns
Nothing.
Description
Imports the specified file at the specified location.
Example
The following command imports the specified file and maintains its aspect ratio:
filepath The fileURL of the file that contains the symbol to be copied.
whichSymbol The index of the symbol within the document, which is specified in the filepath.
Returns
Nothing.
Description
Extracts the component elements from the selected symbol and places copies of those elements in the document.
This function is similar to the dom.importSymbol API. dom.importSymbol places an instance of a symbol in your
document—for example, when you select Edit > Libraries > Buttons, and
dom.importSymbolButNotAsAlias extracts
the component elements from the selected symbol and places copies of those elements in the document.
dom.importSymbolButNotAsAlias does not place in an instance in the document.
dom.inLaunchAndEdit()
Availability
Fireworks MX.
94
Usage
dom.inLaunchAndEdit()
Arguments
None.
Returns
A Boolean value: true if opened by a launch-and-edit operation; false otherwise.
Description
Specifies whether document was opened by a launch-and-edit operation.