Module: layers

layers

The fwlib/layers module includes a number of utility functions and classes that make it easier to inspect and manipulate the layers in a Fireworks document. The native layers API was sufficient back before sub-layers were introduced, but it's now much harder to understand and manipulate the layer structure.

For instance, if an element is selected and you want to move the top-level layer that contains that element up or down in the stack, how do you find the top-level layer? You have to call dom.getParentLayerNum(dom.currentLayerNum), check if the if result is -1, and if not, call it again with the result, until you get a -1. There's also no easy way to figure out which layer is directly above or below another one. The classes and functions in this module simplify this process.

Source:
  • lib/fwlib/layers.js, line 5

Classes

Layer
LayerTree

Methods

<static> layers.alertLayers

Displays a textual representation of the layer structure of a document in an alert dialog. This can help with debugging a command that modifies the layer structure, so you can get a snapshot of the layers at different points in the command.

Each line in the representation shows the layer index and the name of the layer. The indentation of the line indicates the parent/child relationships of the layers, simliar to how they're shown in the Layers panel.

5: Web Layer
2: Layer 3
    3: Layer 5
        4: Layer 4
0: Layer 1
    1: Layer 2
Parameters:
Name Type Argument Default Description
inDom DOM <optional>
currentDOM

The document whose layers should be shown. This defaults to the current document if not specified.

inJustReturnOutput Boolean <optional>
false

Pass true to suppress the alert() dialog and just return the layer structure as a string.

Source:
  • lib/fwlib/layers.js, line 1326
Returns:

If inJustReturnOutput is true, a string representation of the document's layer stack. Otherwise, nothing.

Type
String

<static> layers.copyLayer

Copies the elements on a layer from one document to another. This method is provisional and may not work in all cases.

Parameters:
Name Type Argument Default Description
inLayer Layer

The Layer instance to copy.

inTargetDom DOM

The document to copy the layer's elements to.

inSourceDom DOM <optional>
currentDOM

The document to copy the layer's elements from. If this isn't included, the current document is used as the source.

Source:
  • lib/fwlib/layers.js, line 1047

<static> layers.copyLayerBetweenPages

Copies the elements on a layer from one page to another in the same document. This method is provisional and may not work in all cases.

Parameters:
Name Type Description
inLayer Layer

The Layer instance to copy.

inSourcePageIndex Number

The index of the page to copy from.

inTargetPageIndex Number

The index of the page to copy to.

Source:
  • lib/fwlib/layers.js, line 1135
To Do:
  • Ensure that elements get copied to the appropriately named layer.

<static> layers.getLayerIndexByName

Returns the index of the named layer.

Parameters:
Name Type Argument Description
inLayerName String

The name of the index.

inDom DOM <optional>

The document to look in to find the layer. This defaults to the current document if not specified.

Source:
  • lib/fwlib/layers.js, line 1229
Returns:

The index of the layer in the Fireworks layers stack, or -1 if a layer with that name can't be found.

Type
Number

<static> layers.getTopLayerAncestorIndex

Returns the index of the top-level layer that contains the layer specified by inLayerIndex.

Parameters:
Name Type Argument Default Description
inLayerIndex Number

A layer index.

inDom DOM <optional>
currentDOM

The document to look in to find the layer. This defaults to the current document if not specified.

Source:
  • lib/fwlib/layers.js, line 1251
Returns:

The index of the top-level layer in the Fireworks layers stack that contains the layer specified by inLayerIndex.

Type
Number

<static> layers.getTopLayerIndexes

Returns an array of the indexes that correspond to the top-level layers in the document.

Parameters:
Name Type Argument Default Description
inDom DOM <optional>
currentDOM

The document containing the layers, or the current document if not specified.

Source:
  • lib/fwlib/layers.js, line 1276
Returns:

All of the indexes of the top-level layers in the document.

Type
Array