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!

Vegeta
  • 37
  • 6

1 Answers1

5
var a : ArrayCollection = new ArrayCollection();
var b : ArrayCollection = new ArrayCollection();
a.addAll(b);
NTyler
  • 1,397
  • 1
  • 12
  • 20
  • 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.] – Vegeta Jul 02 '13 at 20:11
  • Do you have any suggestions @NTyler? – Vegeta Jul 03 '13 at 03:39
  • 1
    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); }` – NTyler Jul 06 '13 at 15:06