Skip to content

Instantly share code, notes, and snippets.

@sacrifs
Created April 21, 2012 13:49
Show Gist options
  • Save sacrifs/2437153 to your computer and use it in GitHub Desktop.
Save sacrifs/2437153 to your computer and use it in GitHub Desktop.
選択中のオブジェクトのインスタンス名のリストを取得するJSFL
/**
* Get Selected Instance Name
* @author sacrifs
*/
var _doc = fl.getDocumentDOM();
function main(){
fl.outputPanel.clear();
var selectedItems = _doc.selection;
var numItem = selectedItems.length;
var isFlashProgram = confirm("output for ActionScript?");
if(numItem == 0){
fl.trace("nothing.");
}
else{
for(var i = 0; i < numItem; i++){
var elem = selectedItems[i];
outputName(elem, isFlashProgram);
}
fl.trace("complete.");
}
}
/**
* output instance mame
* @param elem:Element
* @param isFlash:Boolean
*/
function outputName(elem, isFlash){
//instance or text
if(elem.elementType == "instance" || elem.elementType == "text"){
if(elem.name != ''){
if(isFlash){
var type = (elem.elementType == "instance") ? "Sprite" : "TextField";
fl.trace("public var " + elem.name + ":" + type + ";");
}
else{
fl.trace(elem.name);
}
}
}
//shape
else if(elem.elementType == 'shape'){
//
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment