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