0

I'm pretty new to Flex but I'm taking a few tutorials to try and get the hang of a project I'm working on.

I'm using AS3.

I currently need to just add an arraycollection (A) to an arraycollection (B) that is populating a datagrid. So when the user clicks an option on the left column, the resulting arraycollection (A) will be added to the currently displayed results in the right column.

I think I can just loop through A adding each row to B by using the additem() function, but I'm not exactly sure what syntax to use the loop properly. I also wondered if there was some property of the arraycollection that would give me the number of iterations I'm going to make [something like arraycollectionA.countArrays]

Any help would be greatly appreciated.

Thanks!

1 Answer 1

5
var a : ArrayCollection = new ArrayCollection();
var b : ArrayCollection = new ArrayCollection();
a.addAll(b);
Sign up to request clarification or add additional context in comments.

3 Comments

Hi, I have a followup question. What if I wanted to filter out any duplicate entries? So if B already had a record that was in A, it wouldn't be added? [I realize this may be an entirely different issue, so if I need to repost it as a new question, please let me know.]
Do you have any suggestions @NTyler?
Traditionally you might use a Set for that, but Actionscript doesn't have Sets. To do this with ArrayCollection is fairly simple, you should be able to find an answer with a quick search but I'll show you anyway: for(var x : Object in b) { if(!a.contains(x)) a.addItem(x); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.