object_helper.as 584 B

12345678910111213141516171819202122232425262728
  1. package {
  2. public class object_helper {
  3. //
  4. // merge two objects, one from the user
  5. // and is JSON, the other is the default
  6. // values this object should have
  7. //
  8. public static function merge( o:Object, defaults:Object ):Object {
  9. for (var prop:String in defaults ) {
  10. if( o[prop] == undefined )
  11. o[prop] = defaults[prop];
  12. }
  13. return o;
  14. }
  15. public static function merge_2( json:Object, defaults:Object ):void {
  16. for (var prop:String in json ) {
  17. // tr.ace( prop +' = ' + json[prop]);
  18. defaults[prop] = json[prop];
  19. }
  20. }
  21. }
  22. }