Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. /**
  2. * Creates the `newValue` object at the `target`. The `path` is the route to take to get there. <strong>DO NOT</strong> include the target in the path.
  3. * @param target The Object to search
  4. * @param newValue The value to be set
  5. * @param path The path to follow (as an <code>Array</code> of <code>String</code>), not including the final object name
  6. */
  7. public static function setObj(target:Object, newValue:Object, path:Array):void {
  8. if (!path || !(path is Array)) {
  9. return;
  10. }
  11. var l:uint = path.length-1;
  12. for (var i:uint = 0; i < l; i++) {
  13. if (target[path[i]] == null) {
  14. target[path[i]] = {};
  15. }
  16. target = target[path[i]];
  17. }
  18. target[path[path.length-1]] = newValue;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement