Specifies if the document has been edited since it was last saved. When
set to true, closing the document will present the user
with a dialog box asking to save the file.
An object contained within the document which can be used to store data.
The values in this object can be accessed even after the file has been
closed and opened again. Since these values are stored in a native
structure, only a limited amount of value types are supported: Number,
String, Boolean, Item, Point, Matrix.
// When you create a new Document it always contains
// a layer called 'Layer 1'
print(document.layers); // Layer (Layer 1)
// Create a new layer called 'test' in the document
var newLayer = new Layer();
newLayer.name = 'test';
print(document.layers); // Layer (test), Layer (Layer 1)
print(document.layers[0]); // Layer (test)
print(document.layers.test); // Layer (test)
print(document.layers['Layer 1']); // Layer (Layer 1)
Read-only.
Returns:
Array of Layer, read-only, also accessible by name
The layer which is currently active. The active layer is indicated in the
Layers palette by a black triangle. New items will be created on this
layer by default.
Activates this document, so all newly created items will be placed
in it.
Parameters:
focus: Boolean — When set to true, the document window is
brought to the front, otherwise the window sequence remains the
same. Default is true. — optional
Returns all items that match a set of attributes, as specified by the
passed map. For each of the keys in the map, the demanded value can
either be true or false.
Sample code:
// All selected paths and rasters contained in the document.
var selectedItems = document.getItems({
type: [Path, Raster],
selected: true
});
// All visible Paths contained in the document.
var visibleItems = document.getItems({
type: Path,
hidden: false
});
Parameters:
attributes: ItemAttributes — an object containing the various attributes to check
for.
Invalidates the rectangle in artwork coordinates. This will cause all
views of the document that contain the given rectangle to update at the
next opportunity.
tolerance: Number — the hit-test tolerance in view coordinates (pixels at
the current zoom factor). correct results for large values are not
guaranteed — optional, default: 2