My simple code:
/*
* read all and push to list
*/
private function readObject(mc:Object):void {
var mcs:* = null;
var mci:* = null;
for (var i:int = 0; i < mc.numChildren; i++ ) {
mcs = mc.getChildAt(i);
list.push(mcs);
if (mcs is MovieClip) {
if (mcs.numChildren > 0) {
readObject(mcs);
}
}
}
}
/**
* Example:
* input: object[child]
* output: string[root.parent.parent.child]
* @param object
* @return string
*/
private function readParent(object:*):String {
var str:String = "";
if (object != null) {
var temp:Array = new Array();
while (object.parent != null) {
temp.push(object.name);
object = object.parent;
}
temp = temp.reverse();
}
return String(temp).split(",").join(".");
}
Demo
0 comments:
Post a Comment