views:

48

answers:

2
+1  Q: 

Group for Array

Possible to group multiple MC and post it in an Array?

exp: array([mc1,mc2,mc3],[ac1],[bc1,b2])

If its possible how could it be achieve in a for...loop function?

A: 

I could understand your question wrong, but it seems that you just need multidimensional array, i.e. array of arrays:


var array: Array = new Array(
                         new Array(mc1,mc2,mc3),
                         new Array(ac1),
                         new Array(bc1, b2)
                   );

Pavel Alexeev
BTW, I think using [] is better for both performance and readability.
Andy Li
+3  A: 

You are almost there.

var mcArray1:Array = [[mc1, mc2, mc2], [ac1], [bc1,b2]];
//or
var mcArray2:Array = new Array([mc1, mc2, mc2], [ac1], [bc1,b2]);

//you can access them with for loops
var array:Array;
var mc:MovieClip;

for(var i:int = 0; i < mcArray.length; i++)
{
  array = mcArray1[i];
  for(var j:int = 0; j < array.length; j++)
  {
    mc = MovieClip(array[j]);
    mc.x = 20;//do whatever you want with it.
  }
}
Amarghosh