Skip to main content
Participant
May 7, 2020
Question

jsfl question - getting layers in a movieclip

  • May 7, 2020
  • 2 replies
  • 939 views

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!

    This topic has been closed for replies.

    2 replies

    Participating Frequently
    June 10, 2020

    How do you debug JSFL files?

    Vladin M. Mitov
    Inspiring
    May 7, 2020

    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 1998Member of Flanimate Power Tools team - extensions for character animation
    RobCrisPAuthor
    Participant
    May 8, 2020

    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!