# Remove link between to variables

**URL:** <https://forum.kirupa.com/t/remove-link-between-to-variables/262855>\
**Category:** Uncategorized\
**Created:** [June 10, 2008, 3:54pm UTC](https://forum.kirupa.com/t/remove-link-between-to-variables/262855 "2008-06-10T15:54:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lone\_wolf](https://avatars.discourse-cdn.com/v4/letter/l/839c29/32.png) [@Lone\_wolf](https://forum.kirupa.com/u/Lone_wolf)\
**Post date:** [June 10, 2008, 3:54pm UTC](https://forum.kirupa.com/t/remove-link-between-to-variables/262855/1 "2008-06-10T15:54:51Z")

</div>

Greetings!

I’ve banging my head against the wall for a few days now about this problem:

Code:

\<?xml version=“1.0” encoding=“utf-8”?\>  
\<mx:Application  
xmlns:mx=“[http://www.adobe.com/2006/mxml](http://www.adobe.com/2006/mxml)” creationComplete=“init()”  
layout=“absolute”\>  
\<mx:Script\>  
\<![CDATA[  
import mx.collections.ArrayCollection;

```
        public var myArr:ArrayCollection = new ArrayCollection(new Array("1","2","3","4","5"));
        
        public var myTest:ArrayCollection = new ArrayCollection()
        
        public function init():void{
            myTest = new ArrayCollection(myArr.source);
            myTest.removeItemAt(2);
            trace(myTest.length);
            trace(myArr.length);
        }
    ]]&gt;
&lt;/mx:Script&gt;

```

\</mx:Application\>

the code above results in an output of

Code:

4  
4

But I want it to result in  
Code:

4  
5

---

<div class="post-metadata">

**Author:** ![Iamthejuggler](https://avatars.discourse-cdn.com/v4/letter/i/ecc23a/32.png) [@Iamthejuggler](https://forum.kirupa.com/u/Iamthejuggler)\
**Post date:** [June 10, 2008, 4:15pm UTC](https://forum.kirupa.com/t/remove-link-between-to-variables/262855/2 "2008-06-10T16:15:10Z")

</div>

I believe that because you are pointing it to the arrayCollection’s source it isn’t making a new instance of that source, it is using the same source for both arrays, so when you change one both arraycollections change. Change the line to:

myTest = new ArrayCollection(myArr.toArray());

and that should work.

---

<div class="post-metadata">

**Author:** ![Lone\_wolf](https://avatars.discourse-cdn.com/v4/letter/l/839c29/32.png) [@Lone\_wolf](https://forum.kirupa.com/u/Lone_wolf)\
**Post date:** [June 10, 2008, 5:25pm UTC](https://forum.kirupa.com/t/remove-link-between-to-variables/262855/3 "2008-06-10T17:25:01Z")

</div>

i’ll give it a go!

but why doesn’t this occure with Strings for example??

thanks!!
