-1

Example of the my problem.

 var array_1:Array = new Array();
 array_1[0] = [2,4,6,8];

 var array_2:array = new Array();
 array_2[0] = [10,12,14,16];
 array_2[1] = [18,20,22,24];

 // and the out come I want it to be is this  
 trace(array_1[0]) // 2,4,6,8,10,12,14,16,20,22,24

 // I did try  array_1[0] += array_2[0] but it didn't work currently   

Any suggestion would be great.

3

2 Answers 2

0

This will perform what you are looking for and also allows you to add multiple rows of data to array_1 or array_2

var array_1:Array = new Array();
array_1[0] = [2,4,6,8];

var array_2:Array = new Array();
array_2[0] = [10,12,14,16];
array_2[1] = [18,20,22,24];

var combinedArray:Array = new Array();
for( var i:int = 0; i < array_1.length; i++ ) {
    combinedArray = combinedArray.concat(array_1[i]);
}
for( i = 0; i < array_2.length; i++ ) {
    combinedArray = combinedArray.concat(array_2[i]);
}

trace(combinedArray);
Sign up to request clarification or add additional context in comments.

Comments

0

As stated in the comments, you can use the concat method:

 var array_1:Array = new Array();
 array_1[0] = [2,4,6,8];

 var array_2:array = new Array();
 array_2[0] = [10,12,14,16];
 array_2[1] = [18,20,22,24];

 array_1[0] = array_1[0].concat(array_2[0]).concat(array_2[1]);

This, of course, is very messy looking. I am wondering why you are storing arrays inside of other arrays for no discernible reason.

1 Comment

The messy reason is because array_2 is a temporary array which is likely to change a few times before it goes to the main array of array_1. < Thanks for the reply and the help

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.