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

Can't Select a Layer by Name in JSFL

Community Beginner ,
Aug 29, 2023 Aug 29, 2023

Copy link to clipboard

Copied

I'm stuck with trying to select a layer by name.
I must be missing something super basic but I can't figure it out.

var dom = fl.getDocumentDOM();
var timeline = dom.getTimeline();

var targetLayer = timeline.findLayerIndex('Keys')
if (targetLayer !== undefined) {
	fl.trace(targetLayer)
	timeline.currentLayer = targetLayer;}

// If the target layer is not found, create a new layer and select it
else {
	timeline.addNewLayer('Keys');}

 The fl.trace(targetLayer) returns a number (7), but the selected layer doesn't change. I also tried setSelectedLayers with the same result.

timeline.setSelectedLayers(targetLayer);

 If I put a plain number in place of targetLayer it selects that layer no problem. Is this a bug or is there a work around?

TOPICS
Code , Timeline

Views

192

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 , Aug 29, 2023 Aug 29, 2023

targetLayer (if it's defined) is an array.  ie, if you use unique layer names, try:

 

timeline.setSelectedLayers(targetLayer[0]);

Votes

Translate

Translate
Community Expert ,
Aug 29, 2023 Aug 29, 2023

Copy link to clipboard

Copied

targetLayer (if it's defined) is an array.  ie, if you use unique layer names, try:

 

timeline.setSelectedLayers(targetLayer[0]);

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 Beginner ,
Aug 30, 2023 Aug 30, 2023

Copy link to clipboard

Copied

That makes sense, thank you!

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 ,
Aug 30, 2023 Aug 30, 2023

Copy link to clipboard

Copied

LATEST

you're welcome.

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 ,
Aug 30, 2023 Aug 30, 2023

Copy link to clipboard

Copied

Hi.

 

Please try this:

var tl = fl.getDocumentDOM().getTimeline();
var layerIndex = tl.findLayerIndex("Keys");
tl.setSelectedLayers(layerIndex[0]);

 

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