# Question about multiple buttons

**URL:** <https://forum.kirupa.com/t/question-about-multiple-buttons/304855>\
**Category:** Uncategorized\
**Created:** [February 15, 2010, 3:06pm UTC](https://forum.kirupa.com/t/question-about-multiple-buttons/304855 "2010-02-15T15:06:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zenor](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/zenor/32/3634_2.png) [@Zenor](https://forum.kirupa.com/u/Zenor)\
**Post date:** [February 15, 2010, 3:06pm UTC](https://forum.kirupa.com/t/question-about-multiple-buttons/304855/1 "2010-02-15T15:06:32Z")

</div>

Hello everyone!

So, I’ve built a project which contains some buttons and every one has an instance name.

My code works great, but if I have, let’s say 20 buttons on the stage, I would need to use the same code I used below, 20 times?  
I remember that in AS2 we could create a function and use it for every button without using it’s instance name. Is that possible on AS3 so that my code doesn’t get huge?

Thanks in advance!:hugegrin:

```auto
btn1.addEventListener(MouseEvent.CLICK, btnClicked)
btn1.addEventListener(MouseEvent.MOUSE_OVER, btnOver)
btn1.addEventListener(MouseEvent.MOUSE_OUT, btnOut)
btn1.buttonMode = true;

function btnClicked(event:MouseEvent):void
{
	btn1.navigateToURL(new URLRequest("http://www.google.com"));
}

function btnOver(event:MouseEvent):void
{
	btn1.gotoAndPlay("over");
}

function btnOut(event:MouseEvent):void
{
	btn1.gotoAndPlay("out");
}

```
