Advertisement
Guest User

UpdateObject.js

a guest
Dec 28th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. function getComponentByName(parent_object, component_name) {
  2. if ((parent_object == null) || (component_name == null)) return null;
  3.  
  4. var cnt = parent_object.children.length;
  5. //console.log("parent has ",cnt," children");
  6.  
  7. for (var i=0; i<cnt; i++) {
  8. var sub_object = parent_object.children[i];
  9. //console.log("Child[",i,"] name=[",sub_object.objectName,"]");
  10. if (sub_object.objectName === component_name) {
  11. //console.log("Found [",component_name,"] !");
  12. return sub_object;
  13. }
  14. //make some recursion
  15. if (sub_object.children.length > 0) {
  16. var sub_child = getComponentByName(sub_object, component_name);
  17. if (sub_child != null) {
  18. console.log("got sub_child ",sub_child);
  19. return sub_child;
  20. }
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement