You need to make the second ArrayCollection a copy of the first, and not
just a wrapper:

var myTest:ArrayCollection = new ArrayCollection();
// Slice is a method that returns a new array consisting of a 'slice'
// of elements from the source array. It takes two optional arguments,
// startIndex and endIndex. The first defaults to 0, the last to the
// end of the array, so calling it without arguments gives you a
// copy of the entire source array
myTest.source = myArr.source.slice();
-- 
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com

-----Original Message-----
From: mariovandeneynde <[EMAIL PROTECTED]>
Reply-To: flexcoders@yahoogroups.com
To: flexcoders@yahoogroups.com
Subject: [flexcoders] remove link between to variables
Date: Tue, 10 Jun 2008 15:53:26 -0000

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"; 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);
}
]]>
</mx:Script>
</mx:Application>

the code above results in an output of

Code:

4
4

But I want it to result in
Code:

4
5




 


Reply via email to