# Object weirdness

**URL:** <https://forum.kirupa.com/t/object-weirdness/311780>\
**Category:** flash\
**Created:** [July 16, 2010, 9:11am UTC](https://forum.kirupa.com/t/object-weirdness/311780 "2010-07-16T09:11:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![itworks](https://avatars.discourse-cdn.com/v4/letter/i/46a35a/32.png) [@itworks](https://forum.kirupa.com/u/itworks)\
**Post date:** [July 16, 2010, 9:11am UTC](https://forum.kirupa.com/t/object-weirdness/311780/1 "2010-07-16T09:11:03Z")

</div>

Hi everyone,

I’ve been debating with something for the last few hours that never happened to me before.

picture this class:

```auto

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.
