• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Reversing layer order

Explorer ,
Mar 22, 2023 Mar 22, 2023

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
  //  ????
}

 

TOPICS
How to , Missing feature , Other , Product issue

Views

268

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 22, 2023 Mar 22, 2023

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

Votes

Translate

Translate
Community Expert ,
Mar 22, 2023 Mar 22, 2023

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 22, 2023 Mar 22, 2023

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 22, 2023 Mar 22, 2023

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines