Hi everyone,
I’ve been debating with something for the last few hours that never happened to me before.
picture this class:
package {
public class Api {
static public var _default:Object;
static public var _data:Object;
public function Api (data:Object) {
_default = data;
_data = data;
}
static public function updateData (obj:Object):void {
for (var k:String in obj) {
_data[k] = obj[k];
}
}
}
Ok so the code stores the _default object and _data objects with the initial values passed to the constructor and then there’s a method to change properties in the _data object.
Now, the problem is that if i suddenly feel like resetting the values to the initial ones when i do:
Api.updateData(Api._default); // doesn’t work
Api._data = Api._default; // doesn’t work
and if i:
Api.updateData({someVar: ‘hello’});
trace(Api._default.someVar);
trace(Api._data.someVar);
They both come up with the same values, I’m never changing the _default object so why is it updating along with the _data one?!
Any ideas? Thanks in advance.