Question about multiple buttons

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:

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");
}