The web site for Flash ActionScript 3.0 game developers

 
         
   

having problem w/ arrays

Hi, I'm having a problem getting instances in an array to work. I'm making a picture gallery, and have instances of each picture already on the stage. I want to randomize the order of the pictures, and then move them to a game grid.

The problem comes in that last step: moving them to the game grid. I grab elements from several arrays and then add them together to get the final pixies array. Since instances of each pixie are already on the stage, I should be able to use pixies[i].x & pixies[i].y to move them to the grid. Instead, I keep getting bumpkis. No error messages -- just all of the pixies obtinately in their original positions. I've also tried to addChild(pixies[i]), but no new instances are created.

I use trace commands for each step, so I know my arrays are working. Can anyone tell me what I'm doing wrong? Thanx.

//// shuffling clips ...
while (pixies4.length > 0) {
pixies.push(pixies4.splice(Math.round(Math.random() * (pixies4.length - 1)), 1));
}

trace(" & pixies now = ...");
for (i = 0; i < pixies.length; i++) {
trace(pixies[i]);
}

trace(" placing pixies on grid ... 1st row")
//// setting up pixies, 1st row
for (i = 0; i < 7; i++) {
pixies[i].x = (124 * i) + 260;
pixies[i].y = 50;
}



Copyright Gary Rosenzweig