Copy link to clipboard
Copied
Is there a way to reverse layer order?
I can't see any option to do it, or a way in JSFL to set a layer index.
// Get the total number of layers in the document
var numLayers = fl.getDocumentDOM().getTimeline().layers.length;
// Loop through each layer and set its new index
for (var i = 0; i < numLayers; i++) {
var currentLayer = fl.getDocumentDOM().getTimeline().layers[i];
var newIndex = numLayers - i;
// Set the new index for the layer
// ????
}
Hi.
Use the reorderLayer method from the Timeline object. Like this:
var dom = fl.getDocumentDOM();
var tl = dom.getTimeline();
var layers = tl.layers;
layers.forEach(function(layer, index)
{
tl.reorderLayer(0, layers.length - 1 - index, false);
});
I hope it helps.
Regards,
JC
Copy link to clipboard
Copied
Hi.
Use the reorderLayer method from the Timeline object. Like this:
var dom = fl.getDocumentDOM();
var tl = dom.getTimeline();
var layers = tl.layers;
layers.forEach(function(layer, index)
{
tl.reorderLayer(0, layers.length - 1 - index, false);
});
I hope it helps.
Regards,
JC
Copy link to clipboard
Copied
Thanks, I tweaked it to work on selected layers:
var dom = fl.getDocumentDOM();
var tl = dom.getTimeline();
var selectedLayers = tl.getSelectedLayers();
selectedLayers.forEach(function(layer, index)
{
tl.reorderLayer(0, selectedLayers.length - 1 - index, false);
});
Also, is there newer docs for jsfl then cs5? It seems weird, but I havn't found anything more recent.
Copy link to clipboard
Copied
Great! You're welcome!
The most recent version of the JSAPI documentation is in GitHub:
https://github.com/AdobeDocs/developers-animatesdk-docs/blob/master/index.md
Regards,
JC