# This cant be the best way to make Button Rollovers

**URL:** https://forum.kirupa.com/t/this-cant-be-the-best-way-to-make-button-rollovers/300370
**Category:** Uncategorized
**Created:** [November 19, 2009, 9:54pm UTC](https://forum.kirupa.com/t/this-cant-be-the-best-way-to-make-button-rollovers/300370 "2009-11-19T21:54:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Solidus](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@Solidus](https://forum.kirupa.com/u/Solidus)
#### Post date: [November 19, 2009, 9:54pm UTC](https://forum.kirupa.com/t/this-cant-be-the-best-way-to-make-button-rollovers/300370/1 "2009-11-19T21:54:24Z")

</div>

I currently have a flash file that has a whole bunch of buttons that are MC’s with rollover and out states that open up a PDF when clicked.

![](http://forum.kirupa.com/uploads/kirupa/5949/405a0991aa11de97.jpg)

For each number (12-33) I have the MC with a new instance name and I am calling them with the following code:

```auto

stop();
over12.addEventListener(MouseEvent.CLICK, over12Click);
over12.addEventListener(MouseEvent.MOUSE_OVER, over12Over);
over12.addEventListener(MouseEvent.MOUSE_OUT, over12Out);
function over12Click(event:MouseEvent):void {
    navigateToURL(new URLRequest("catalog/12.pdf"));
}
function over12Over(event:MouseEvent) :void
{
    event.currentTarget.gotoAndPlay("over");    
} 
function over12Out(event:MouseEvent) :void
{
    event.currentTarget.gotoAndPlay("out");    
}

```

So for each button I have this huge mess of code. There has to be a cleaner and more efficient way of doing this. Can you guys suggest anything?
