Grids with for loops

Hello all,

Pretty basic stuff this, but I’m not sure why it isn’t working.
I have a movie clip in library which I want to attach to the stage multiple times to form a perfect grid. I am using th following code but it is only laying the movieclips out on the x axis:

for (var y:Number = 0; y< 100; y = y + 10){
for(var x:Number = 0; x < 100; x = x + 10){
this.attachMovie(“mc_circle”, “mc_circle” + x, x,{_x:x, _y:y});
}
}

Any ideas why this isn’'t working?

thanks

http://www.kirupa.com/developer/actionscript/grid.htm

I need to duplicate the clip don’t I! Doh.

there are many ways to do this

i prefer attachMovie - using a method like this … although i would normally attach to emptyMovie clip so i can scale or move the grid as i wish

for (i=0; i<10; i++) {
 for (h=0; h<10; h++) {
  var mc:MovieClip = this.attachMovie("circle_mc", "circle_mc"+this.getNextHighestDepth(), this.getNextHighestDepth());
  mc._x = i*mc._width;
  mc._y = h*mc._height;
 }
}

Hey thanks

So simple when you have been shown how. I agree that the attachMovie method is better… I didn’t really want unused instances laying around off the stage. Thanks again.

yw