Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * 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.
- * @param target The Object to search
- * @param newValue The value to be set
- * @param path The path to follow (as an <code>Array</code> of <code>String</code>), not including the final object name
- */
- public static function setObj(target:Object, newValue:Object, path:Array):void {
- if (!path || !(path is Array)) {
- return;
- }
- var l:uint = path.length-1;
- for (var i:uint = 0; i < l; i++) {
- if (target[path[i]] == null) {
- target[path[i]] = {};
- }
- target = target[path[i]];
- }
- target[path[path.length-1]] = newValue;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement