PDA

View Full Version : Array.slice()



Ariff
March 9th, 2008, 08:53 PM
Hi,

i have an fileArray consisting of 6 mc's. i have a second containerArray that consists of 3 containermcs.

i would like to obtain the following :

containerArray[0] = containerMC0;
containerArray[1] = containerMC1;
containerArray[2] = containerMC2;

containerMC0.addChild(fileArray[0]);
containerMC0.addChild(fileArray[1]);

containerMC1.addChild(fileArray[2]);
containerMC1.addChlid(fileArray[3]);

containerMC2.addChild(fileArray[4]);
containerMC2.addChild(fileArray[5]);

im not very good at writing loops. So when this is done, i could go and say :

addChild(containerArray[0])

this would give me containerMC0 consisting of the mc's fileArray[0] & [1]

any ideas on how i could do this ?

FlashingDan
March 10th, 2008, 12:27 AM
Howdy Ariff :)

If I understand what you're looking for correctly, I think this loop should do it for you:



for(var i = 0; i<containerArray.length; i++)
{
containerArray[i].addChild(fileArray[i*2])
containerArray[i].addChild(fileArray[i*2+1])
}


If this isn't right, I'm gonna need more information to be able to help ya out.

-Dan