getting symbol from the library folder… jsfl

Community Beginner ,
Mar 27, 2020

Copy link to clipboard

Copied

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);
}
}

TOPICS
Code, How to, Missing feature, Other

Views

272

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

1 Correct Answer

Adobe Community Professional , Mar 27, 2020
ClayUUID Adobe Community Professional , Mar 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.

Likes

Translate

Translate
Jump to answer Jump to answer
Adobe Community Professional ,
Mar 27, 2020

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more