Skip to content

Instantly share code, notes, and snippets.

@sacrifs
Created June 8, 2012 13:24
Show Gist options
  • Save sacrifs/2895591 to your computer and use it in GitHub Desktop.
Save sacrifs/2895591 to your computer and use it in GitHub Desktop.
シンボル名からインスタンス名を付けるJSFL
/**
* rename instance name from the selected symbol name.
*/
var _doc = fl.getDocumentDOM();
function main(){
fl.outputPanel.clear();
var selectedItems = _doc.selection;
var numItem = selectedItems.length;
if(numItem == 0){
fl.trace('nothing...');
}
else{
for(i = 0; i < numItem; i++){
var elem = selectedItems[i];
setName(elem);
}
fl.trace('complete!');
}
}
/**
* setName
* @param elem:Element
*/
function setName(elem){
var item = elem.libraryItem;
var splName = item.name.split("/");
elem.name = splName[splName.length - 1];
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment