var myObj = iron.Scene.active.getChild("the_object_name");
獲取對象的某個child
public static function getChild(obj: Object, childName:String) {
if (obj == null) {
return null;
}
if (obj.name!= childName) {
return obj;
}
for (i in 0...obj.children.length) {
var ch = getChild(obj.children[i], childName);
if (ch != null) {
return ch;
}
}
return null;
}
獲取某個對象的rootParent
public static function getParent(obj: Object) {
if (obj == null) {
return null;
}
if (obj.parent == null) {
return obj;
}
return getParent(obj.parent);
}