Copy link to clipboard
Copied
Hi,
I am new to as3 and need your help.
I would like to combine two arrays such that the elements of each array follow each other in alternating order.
For example, if Array1=(1,2,3) and Array2=(A,B,C), I would like my combined Array to look like (1,A,2,B,3,C).
When I use the concatenate function the arrays are combined like this: (1,2,3,A,B,C) and this is not what I want.
Please let me know if you know the answer.
Thank you so much.
Melisa
One way to do it... you could build a new array from the two using a loop....
var Array1:Array = [1,2,3];
var Array2:Array = ["A","B","C"];
var combinedArray:Array = new Array();
for(var i:int=0; i<Array1.length; i++){
combinedArray.push(Array1);
combinedArray.push(Array2);
}
trace(combinedArray);
Copy link to clipboard
Copied
One way to do it... you could build a new array from the two using a loop....
var Array1:Array = [1,2,3];
var Array2:Array = ["A","B","C"];
var combinedArray:Array = new Array();
for(var i:int=0; i<Array1.length; i++){
combinedArray.push(Array1);
combinedArray.push(Array2);
}
trace(combinedArray);
Copy link to clipboard
Copied
Dear Ned,
Thank you so much! This is really helpful! I have been working in this for long hours without any success.
Thanks!
Melisa
Copy link to clipboard
Copied
You're welcome Melisa
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more