# Little problem with a "for" loop

**URL:** <https://forum.kirupa.com/t/little-problem-with-a-for-loop/181445>\
**Category:** Uncategorized\
**Created:** [March 9, 2006, 12:59pm UTC](https://forum.kirupa.com/t/little-problem-with-a-for-loop/181445 "2006-03-09T12:59:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![5TEF](https://avatars.discourse-cdn.com/v4/letter/5/85e7bf/32.png) [@5TEF](https://forum.kirupa.com/u/5TEF)\
**Post date:** [March 9, 2006, 12:59pm UTC](https://forum.kirupa.com/t/little-problem-with-a-for-loop/181445/1 "2006-03-09T12:59:55Z")

</div>

here my AS code :

```auto

for (i=1; i<20; i++) {
this["lc"+i].onRollOver = function() {
    this["p"+i].gotoAndPlay("go");
};
this["lc"+i].onRollOut = function() {
    this["p"+i].gotoAndPlay("out");
};
}

```

“lc+i” is a mc button.  
“p+i” is a another mc button.

the problem is only the lc20 and p20 button work !  
( i have 20 buttons, and the number of “lc” must be the same as “p”)

the “for” loop don’t consider lc1 to lc20 and p1 to p20 buttons !!

what’s the problem and the tip ?

thanks
