# Does "For" looping work this way?

**URL:** <https://forum.kirupa.com/t/does-for-looping-work-this-way/171271>\
**Category:** flash\
**Created:** [December 3, 2005, 3:02pm UTC](https://forum.kirupa.com/t/does-for-looping-work-this-way/171271 "2005-12-03T15:02:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mecha](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mecha](https://forum.kirupa.com/u/mecha)\
**Post date:** [December 3, 2005, 3:02pm UTC](https://forum.kirupa.com/t/does-for-looping-work-this-way/171271/1 "2005-12-03T15:02:08Z")

</div>

Hey guys,

I am trying to cut down on coding by using the “for loop” function, but I do not know if this is possible in my situation. I am not duplicating MC buttons, rather the code on frame 1 which assigns functions to hand placed buttons.

I have a sub menu which currently has 5 buttons, but may go up to 20 or 30. This will need too much hand coding, so in comes the “for loop” deal, but am I doing this right?

```auto
for (myCounter = 0; myCounter < 5; myCounter++) {
		btnnumber = myCounter+1;
		workbtnnumber = "subabout.about" + btnnumber;
		trace(workbtnnumber)
//script to be repeated 5 times to create behaviours for 5 buttons labelled "about1, about2, etc in MC called "subabout"
workbtnnumber.onRollOver = function() {
	fadeIn = false;
	fade(subabout, 50, subwork, subplay);
};
workbtnnumber.onRollOut = function() {
	fadeIn = true;
	fade(subabout);
};
//End Repeated Script - If this works, you should be able to rollover the sub options of the first box without them dissapearing!
};

```

Any help would be greatly appreciated as I have tried myself for some time before asking.

mecha
