# Function to add functionality to a group of buttons

**URL:** <https://forum.kirupa.com/t/function-to-add-functionality-to-a-group-of-buttons/268884>\
**Category:** Uncategorized\
**Created:** [August 20, 2008, 1:53am UTC](https://forum.kirupa.com/t/function-to-add-functionality-to-a-group-of-buttons/268884 "2008-08-20T01:53:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CayoHueso](https://avatars.discourse-cdn.com/v4/letter/c/8e8cbc/32.png) [@CayoHueso](https://forum.kirupa.com/u/CayoHueso)\
**Post date:** [August 20, 2008, 1:53am UTC](https://forum.kirupa.com/t/function-to-add-functionality-to-a-group-of-buttons/268884/1 "2008-08-20T01:53:50Z")

</div>

I have a movie with 5 movieclips named section1\_mc, section2\_mc, section3\_mc, etc  
I want to advance to frames 1 - 5 by clicking in each of the movieclips. Do I need to add the onRelease to each of them, or is there a way to do it once for everybody. I tried the code below, but when I click on any of the movieclips the timeline goes to frame 5, the last one. Could you please advice?

Thanks,

```auto

for (i = 1; i < 6; i++) {
	_root["section" + i + "_mc"].onRelease = function(){
        _root.gotoAndStop (i);
       }
}

```
