2009年12月11日 星期五

[JSFL] Update MovieClip's name in Library

1. Select items in the stage
2. Run the script

Here is the script:

if (fl.getDocumentDOM().selection.length > 0)
{
var cur_selection = fl.getDocumentDOM().selection;
var mySelected = new Array();

for(var i in cur_selection)
{
mySelected.push(fl.getDocumentDOM().selection[i]);
}

for(var i in mySelected)
{
var sel = mySelected[i];
var path = sel.libraryItem.name;
var pName = sel.name;
var mc_name = path.substr(path.lastIndexOf("/")+1);
if (mc_name != null)
{
fl.trace(path + "_" + pName);
fl.getDocumentDOM().selectNone();
fl.getDocumentDOM().selection = [sel];

var newMc = fl.getDocumentDOM().convertToSymbol("movie clip", path + "_" + pName, "top left");
fl.getDocumentDOM().selection[0].name = pName;

fl.getDocumentDOM().selection = mySelected;
}
}
}

沒有留言:

張貼留言