• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

getting symbol from the library folder… jsfl

Community Beginner ,
Mar 27, 2020 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

674

Translate

Translate

Report

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

correct answers 1 Correct answer

LEGEND , Mar 27, 2020 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.

Votes

Translate

Translate
LEGEND ,
Mar 27, 2020 Mar 27, 2020

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

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