-1

How do you add two arrays together in AS3? I've run into this problem more often than I can remember the solution to it. So I've tried:

var myArray:Array = array1 + array2;
1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231
  • 2
    This question does not show any research effort. A very quick web search would produce loads of results, including duplicate SO questions. Not limited to: http://stackoverflow.com/questions/7551008/as3-fastest-way-to-merge-multiple-arrays - or - http://stackoverflow.com/questions/335387/cleanly-merge-two-arrays-in-actionscript-3-0 – BadFeelingAboutThis Sep 20 '15 at 06:31
  • I did research but there are two methods that I used to join two arrays together. The first is easy to remember `concat` the second I can't remember at the moment. As soon as I find it I was going to add it to my post. There was some benefit I think. Anyway, I can't accept an answer for two days so might be best to ignore this question for now. :P Update: I remembered it. – 1.21 gigawatts Sep 20 '15 at 06:40

1 Answers1

0

To add two arrays together use the concat method.

This method creates a new array from two separate arrays:

var propertiesStyles:Array = styles.concat(properties);

This method updates the array without making a copy:

styles.push.apply(this, properties);
1.21 gigawatts
  • 16,517
  • 32
  • 123
  • 231