Created
April 21, 2012 13:49
-
-
Save sacrifs/2437153 to your computer and use it in GitHub Desktop.
選択中のオブジェクトのインスタンス名のリストを取得するJSFL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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