# For Loop help

**URL:** <https://forum.kirupa.com/t/for-loop-help/189134>\
**Category:** flash\
**Created:** [May 14, 2006, 3:46am UTC](https://forum.kirupa.com/t/for-loop-help/189134 "2006-05-14T03:46:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![artistwantab](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@artistwantab](https://forum.kirupa.com/u/artistwantab)\
**Post date:** [May 14, 2006, 3:46am UTC](https://forum.kirupa.com/t/for-loop-help/189134/1 "2006-05-14T03:46:26Z")

</div>

This comes up a lot for me. I want to place MC using a for loop that checks the previous MC’s \_x and places the next one 90 pixels to the right. Use an if to check to make sure the \_x is not past 260 if it is move the \_y 90 pixels and reset the the \_x.

```auto
function yelGallery () {
 for (var i = 10; i < 20; i++) {
  var galleryMC:MovieClip = (_root.attachMovie ("galleryMC", "galleryMC" + i, i));
  galleryMC10._x = 70;
  trace (this.galleryMC) -1))
  if (this.galleryMC._x > 260) {
   this.galleryMC._x = 70;
   this.galleryMC._y = /*how do I target the previous MC*/this.galleryMC._y + 90;
  } else {
   this.galleryMC._x = this.galleryMC._x + 90;
  }
  _root.myMCL.loadClip ("Galleries/forSale/tn_forSale/tn_painting" + curPaintingNum + ".jpg", _root.galleryMC);
 }
}

```
