ColorSwatch

A swatch (color, gradient, tint, or mixed ink).

Instance Properties

Name Description Access
eventListeners EventListeners A collection of event listeners. read-only
events Events A collection of events. read-only
id number The unique ID of the Swatch. read-only
index number The index of the Swatch within its containing object. read-only
isValid bool Returns true if the object specifier resolves to valid objects. read-only
label string A property that can be set to any string. read-write
name string The name of the Swatch. read-write
parent The parent of the Swatch (a Application or Document). read-only
parentColorGroup ColorGroup The color group that a swatch belongs to read-only
properties Object A property that allows setting of several properties at the same time. read-write

Methods

addEventListener(
eventType, handler ​[, captures])
 → EventListener
duplicate(
)
 → Swatch
extractLabel(
key)
 → string
getElements(
)
 → Swatch
insertLabel(
key, value)
merge(
with)
 → Swatch
remove(
[replacingWith])
removeEventListener(
eventType, handler ​[, captures])
 → bool
toSource(
)
 → string
toSpecifier(
)
 → string
addEventListener(
eventType, handler ​[, captures=false])
 → EventListener
Adds an event listener.
eventType string The event type.
handler The event handler. Can accept: File or JavaScript Function.
captures bool This parameter is obsolete. (Optional)
duplicate(
)
 → Swatch
Duplicates the Swatch.
extractLabel(
key)
 → string
Gets the label value associated with the specified key.
key string The key.
getElements(
)
 → Swatch
Resolves the object specifier, creating an array of object references.
insertLabel(
key, value)
Sets the label to the value associated with the specified key.
key string The key.
value string The value.
merge(
with)
 → Swatch
Merges the specified swatches with the swatch.
with The swatches to merge. Can accept: Array of Swatches, Swatch or String.
remove(
[replacingWith])
Deletes the swatch.
replacingWith Swatch The swatch to apply in place of the deleted swatch. (Optional)
removeEventListener(
eventType, handler ​[, captures=false])
 → bool
Removes the event listener.
eventType string The registered event type.
handler The registered event handler. Can accept: File or JavaScript Function.
captures bool This parameter is obsolete. (Optional)
toSource(
)
 → string
Generates a string which, if executed, will return the Swatch.
toSpecifier(
)
 → string
Retrieves the object specifier.