Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Multiple ArrayCollections with Single Data Source

Avatar of dbasch
dbasch asked on
Apache Flex
1 Comment1 Solution594 ViewsLast Modified:
Hi All,

This should be a pretty simple question.

Say that I declare two different ArrayCollection's that use the same Array as their source. Then I insert an item into one of those ArrayCollections.

Is the inserted item pushed to the source Array? Does the second ArrayCollection receive a CollectionChange.ADD event?

For instance, I would like to have two different sort's applied to the same Array by using two different ArrayCollections.

I did find this blog post that states something like this is possible:

http://frankieloscavio.blogspot.com/2008/04/using-multiple-arraycollections-with.html

But, there is no example given.

Thanks for all the help,
Derek Basch
// the list that displays the user defined sorted ArrayCollection
// the second ArrayCollection remains sorted by stuffId
//  for add/delete item efficiency
 
<?xml version="1.0" encoding="utf-8"?>
<mx:List xmlns:mx="http://www.adobe.com/2006/mxml" 
dataProvider="{stuffSortedByUserDefinedCollection}"
>
		
	<mx:Script>
		<![CDATA[
			import mx.collections.ArrayCollection;
			
			public var stuff:Array = new Array();
			
			public var stuffSortedByStuffIdCollection:ArrayCollection = new ArrayCollection(stuff);
 
			[Bindable] 
			public var stuffSortedByUserDefinedCollection:ArrayCollection = new ArrayCollection(stuff);
			
			
		]]>
	</mx:Script>
	
</mx:List>
 
 
// The data insert
 
 
public function setStuff( stuff:stuffVO ):void
{
	if (! this.getStuff(stuff.StuffId)) {
		this.stuffCollectionSortedByStuffIdViewCursor.insert( stuff );
	}				
}
ASKER CERTIFIED SOLUTION
Avatar of Gary Benade
Gary BenadeFlag of South Africa image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answers