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

Script: Set currentLayer bug

Participant ,
Oct 26, 2021 Oct 26, 2021

Copy link to clipboard

Copied

Hello, everybody.

 

It's not the first time i try do use the command "fl.getDocumentDOM().getTimeline().currentLayer = myLayerIndex" and it simply does nothing. The crazy thing is that it sometimes work, sometimes don't.

 

(in my case: it's currently selecting the top layer, with 0 as index)

layerIdx0 = 1;

fl.getDocumentDOM().getTimeline().currentLayer = layerIdx0; 

fl.trace("Selected layer: "+fl.getDocumentDOM().getTimeline().currentLayer+" -> i tried to select "+layerIdx0+".");

the output above says: "Selected layer: 0 -> i tried to select 1.".

 

I've tried "fl.getDocumentDOM().getTimeline().setSelectedLayers(0);" as it appears on the documentation, but i get a javascript error saying "setSelectedLayers" is not a function.

 

I've also tried to make a fuction to force the selection of the layer, locking every layer that is not the one i want and making a new selection, and it still does not work.


I really (really) am out of ideas. I'm currently using Adobe Animate 2021.

Thanks in advance

TOPICS
ActionScript , Code , Error , Timeline

Views

156

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 ,
Oct 27, 2021 Oct 27, 2021

Copy link to clipboard

Copied

do you have more than one layer on the main timeline?

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
Participant ,
Oct 28, 2021 Oct 28, 2021

Copy link to clipboard

Copied

Yes. i do.
But i just found the answer. It seems that there is a bug of the function identifying the number you pass. It worked now using a simple line "myLayerIndex= parseInt(myLayerIndex);". This forces myLayerIndex to be a number it recognizes.
My example above was not exactly as i was programming, i was using the "findLayerIndex" function to retrieve it.
Thanks!

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 ,
Oct 28, 2021 Oct 28, 2021

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