# To Save Copy of an Array

**URL:** <https://forum.kirupa.com/t/to-save-copy-of-an-array/293311>\
**Category:** flash\
**Created:** [July 27, 2009, 9:25am UTC](https://forum.kirupa.com/t/to-save-copy-of-an-array/293311 "2009-07-27T09:25:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gitanjali](https://avatars.discourse-cdn.com/v4/letter/g/858c86/32.png) [@gitanjali](https://forum.kirupa.com/u/gitanjali)\
**Post date:** [July 27, 2009, 9:25am UTC](https://forum.kirupa.com/t/to-save-copy-of-an-array/293311/1 "2009-07-27T09:25:47Z")

</div>

How does 1 save copy of an array in AS3 such that changing an element of the copy does not affect the original array?

I have an array of Sprites. I tired using splice(0), concat and even copying the array element by element. But everytime I change a propertly in an element of the copy, the original array gets affected. Why does this happen?

var arrayOfDots2:Array = arrayOfDots1.slice(0);  
for(i=0;i\<5;i++)  
{  
arrayOfDots\*.x = dim + gap + arrayOfDots1\*.x’  
}

Here, why does the x of arrayOfDots1 get changed. How can I prevent this?
