Skip to main content
Known Participant
October 26, 2021
Question

Script: Set currentLayer bug

  • October 26, 2021
  • 1 reply
  • 277 views

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

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
October 27, 2021

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

tiagosaadAuthor
Known Participant
October 28, 2021

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!

kglad
Community Expert
Community Expert
October 28, 2021

you're welcome.