Skip to main content
Firewood:D
Inspiring
November 4, 2023
Answered

What are the ways to select symbols using jsfl?

  • November 4, 2023
  • 2 replies
  • 538 views

Suppose I have a symbol my, and I copy two copies, both of which come from the symbol my. Now I can find the current symbol I selected through the symbol my in the library, but I cannot select the symbol my copy1 or my copy2.
For multiple copies of symbol my, is there a way for jsfl to find and select cpoy1 or cpoy2?
In addition, I did not layer these three symbols. They were all placed on one layer. I wanted to find copies of them to edit, which was very difficult.
I think if you layer the symbol you can find it, but finding it on one layer is difficult, and the copy of the symbol doesn't have any information for reference.
Please help, thank you all

This topic has been closed for replies.
Correct answer Vladin M. Mitov

As I understand it, you have a selected symbol in the library and you want to find all instances of it on the stage and select them. So you could do the following:

 

(function(){
	var doc = fl.getDocumentDOM(),
		tml = doc.getTimeline(),
		cf = tml.currentFrame,
		mySymbol = doc.library.getSelectedItems()[0],
		i, f, j, el;
	

	doc.selectNone();
	for( i = 0; i < tml.layers.length; i++ ){
		f = tml.layers[ i ].frames[ cf ];
		if( ! f ) continue;
		for( j = 0; j < f.elements.length; j++ ){
			el = f.elements[ j ];
			if( el.libraryItem === mySymbol ){
				el.selected = true;
			}
		}
	}

})();

 



2 replies

Vladin M. Mitov
Vladin M. MitovCorrect answer
Inspiring
November 4, 2023

As I understand it, you have a selected symbol in the library and you want to find all instances of it on the stage and select them. So you could do the following:

 

(function(){
	var doc = fl.getDocumentDOM(),
		tml = doc.getTimeline(),
		cf = tml.currentFrame,
		mySymbol = doc.library.getSelectedItems()[0],
		i, f, j, el;
	

	doc.selectNone();
	for( i = 0; i < tml.layers.length; i++ ){
		f = tml.layers[ i ].frames[ cf ];
		if( ! f ) continue;
		for( j = 0; j < f.elements.length; j++ ){
			el = f.elements[ j ];
			if( el.libraryItem === mySymbol ){
				el.selected = true;
			}
		}
	}

})();

 



- Vlad: UX and graphic design, Flash user since 1998Member of Flanimate Power Tools team - extensions for character animation
Firewood:D
Inspiring
November 5, 2023

Thank you very much, you are the best, this will be the starting point for me to move forward

kglad
Community Expert
Community Expert
November 4, 2023

to start,  you need to explain your first step more carefully.

 

you have symbol my.  you right click and click "copy" or "duplicate" or you do something else?