Hi all, I have an object and a temp object now if i do tempObj = obj
and change stuff in tempObj they changes have an effect on obj is there a way i can stop it from doing this? Regards Mark
Hi all, I have an object and a temp object now if i do tempObj = obj
and change stuff in tempObj they changes have an effect on obj is there a way i can stop it from doing this? Regards Mark
Hi
This is a standard behavior in many languages. When you do tempObj = obj you are NOT creating a duplicate object. You are creating another reference to the same object.
I don't think you can change this behavior, and certainly I don't think you should :)
What you need is creating another object, a duplicate of the original object. You can implement a function to do that. Maybe this can help http://blog.comtaste.com/2007/10/improving_object_copy.html
Good luck!
What you are doing is making a reference to the original object not a copy of the original. You should create a deep copy of your object. It seems that someone already wrote the steps to do so...
http://www.as3dp.com/2008/09/23/actionscript-30-clone-a-prelude-to-the-prototype-design-pattern/
Hope this helps