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

jsfl question - getting layers in a movieclip

New Here ,
May 07, 2020 May 07, 2020

Copy link to clipboard

Copied

Hi, could anybody tell me, how to get the layers IN a movieclip with jsfl ?

in this example i am getting the layer called "SH3", that has to be on the main timeline.

 

if (fl.getDocumentDOM().getTimeline().findLayerIndex("SH3") != undefined) {
document.selectNone();
var layerIndex = fl.getDocumentDOM().getTimeline().findLayerIndex("SH3");
fl.getDocumentDOM().getTimeline().setSelectedLayers(layerIndex[0], true);
fl.getDocumentDOM().getTimeline().setLayerProperty('locked', false);
}

 

But how should i do that if the layer is IN A MOVIECLIP-symbol? ( called keyart) , so NOT on the main timeline

 

Thank you!

Views

571

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
Engaged ,
May 07, 2020 May 07, 2020

Copy link to clipboard

Copied

Hi,

You just need to create a function that receives as parameters the timeline and the layer's name. For example:

function searchForLayer( tml, layername ){
	if ( tml.findLayerIndex( layername ) != undefined) {
		document.selectNone();
		var layerIndex = tml.findLayerIndex( layername );
		tml.setSelectedLayers( layerIndex[0], true );
		tml.setLayerProperty( 'locked', false );
	}
}

OK, now we need to get the symbol's timeline:

var lib = fl.getDocumentDOM().library;
var itemIndex = lib.findItemIndex("keyart" );
var myTimeline = lib.items[ itemIndex ].timeline;

...and pass it as a first parameter to the function. The second parameter is the layer's name:

searchForLayer( myTimeline, "SH3" );

 

 

 

- Vlad: UX and graphic design, Flash user since 1998
Member of Flanimate Power Tools team - extensions for character animation

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
New Here ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

Hi, thanks for your answer. It sounds perfectly right, and does not throw any errors, but does not work ( at least for what i want to do )

the following example works ( this time it is the SH1 layer )

 

 

 

 

 

var SH1_Visible = false;

if (fl.getDocumentDOM().getTimeline().findLayerIndex("SH1") != undefined) {
	document.selectNone();
	var layerIndex = fl.getDocumentDOM().getTimeline().findLayerIndex("SH1");
	fl.getDocumentDOM().getTimeline().setSelectedLayers(layerIndex[0], true);
	fl.getDocumentDOM().getTimeline().setLayerProperty('visible', SH1_Visible);
} 

 

 

 

 

 

 in your example , it seems, that the layer SH3 is undefined, but i am not sure, i will keep testing...

In the end i just want to set the layer to invisible, or delete it somehow...  after that another jsfl is reverting that anyway..

 

i wonder if it is really necessary to get into the movieclip´s timeline  (what i thought is the only solution). so is´nt it possible to delete a ibrary item, without going through the layer selection - thing?

 

The whole thing is just about image-export. and the bools on top set to true or false  should just make it possible to set some Images/Texts/Layers to invisible,  it all works, except getting to the content that is inside a symbol. so if you could give me another hint, how i just "get rid of something" , that is in the library ( lets forget the layers if thats possible ).?

 

 

ok sorry for the trouble,  what i wanted works the hard but easy way:

 

if (!SH1_Visible) {lib.deleteItem(["SH1"]);}
else {lib.deleteItem(["SH1b"]);}

 

Thanks again!

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 ,
Jun 10, 2020 Jun 10, 2020

Copy link to clipboard

Copied

LATEST

How do you debug JSFL files?

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