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