Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Add data to an ArrayCollection

Posted on 2009-04-07
3
Medium Priority
?
2,240 Views
Last Modified: 2013-11-11
I have two array collections, and they both have a field in common: sourceCode

I would like to push the data from the 2nd into the first. What's the best way to accomplish this?
0
Comment
Question by:hallikpapa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Expert Comment

by:lexxwern
ID: 24093824
If you want to merge two array collections, you will use the addAll() method. Example below:
var ac1:ArrayCollection;
var ac2:ArrayCollection;
 
// .. .some code ...
 
// merge ac2 into ac1
ac1.addAll( ac2 );
 
// merge ac2 into ac1 at index 5
ac1.addAllAt( ac2, 5 );
 
// add single object
ac1.addItem( new Object );

Open in new window

0
 

Author Comment

by:hallikpapa
ID: 24094032
Thanks. So would I use a cursor on ac1, and then loop through ac2, and when there is a match on the sourceCode on ac1 == ac2, push ac2 into ac1 on that index...somehow?

Mind showing an example? In my scenario, ac2 will have a lot more sourceCode(s) than ac1. So I only want to push it if there is a match.
0
 
LVL 12

Accepted Solution

by:
lexxwern earned 2000 total points
ID: 24094080
Try something like this:
var ac1:ArrayCollection;
var ac2:ArrayCollection;
 
// .. some code ..
 
var currentAc1Object:Object;
var currentAc2Object:Object;
 
for each( currentAc1Object in ac1 ) {
   for each( currentAc1Object in ac2 ) {
      if( currentAc1Object.sourceCode == currentAc2Object.sourceCode ) {
         ac1.addItemAt( currentAc2Object, ac1.getItemIndex(currentAc1Object) + 1 );
      }
   }
}

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question