Skip to main content
Participating Frequently
March 27, 2020
Answered

getting symbol from the library folder… jsfl

  • March 27, 2020
  • 1 reply
  • 968 views

I am looking for some MC I can set by "prompt" window, find it and doing some edits, but my script works only when MC which I am looking for is located in the root of the library without folder. Need some advice on how I can get an element (symbol) from the folder in the library

 

var result = prompt("Enter the name of MC:");
var CurrentFlaFile = an.getDocumentDOM();
var itemsArr = CurrentFlaFile.library.items;
for(var ArreysElement=0; ArreysElement<itemsArr.length; ArreysElement++){
var checkingElement = itemsArr[ArreysElement];
if(checkingElement.itemType=="movie clip" && checkingElement.name == result){
CurrentFlaFile.library.addItemToDocument({x:0, y:0}, result);
CurrentFlaFile.enterEditMode('inPlace');
CurrentFlaFile.getTimeline().addNewLayer("my_layer_ADDED");
CurrentFlaFile.exitEditMode();
CurrentFlaFile.deleteSelection();
an.trace(an.getDocumentDOM().library.items[ArreysElement].name);
}
}

This topic has been closed for replies.
Correct answer ClayUUID

The folder path is just part of the name. The JSFL documentation has numerous examples of this in the library object section.

 

And you don't need to loop through the library to find an item name. That's what findItemIndex() is for.

 

Having users specify a movieclip by name and searching in all folders is a bad idea though, because folders allow you to have multiple movieclips with the same name.

1 reply

ClayUUIDCorrect answer
Legend
March 27, 2020

The folder path is just part of the name. The JSFL documentation has numerous examples of this in the library object section.

 

And you don't need to loop through the library to find an item name. That's what findItemIndex() is for.

 

Having users specify a movieclip by name and searching in all folders is a bad idea though, because folders allow you to have multiple movieclips with the same name.