# Attaching code to multiple buttons cleanly

**URL:** <https://forum.kirupa.com/t/attaching-code-to-multiple-buttons-cleanly/179979>\
**Category:** flash\
**Created:** [February 24, 2006, 12:52pm UTC](https://forum.kirupa.com/t/attaching-code-to-multiple-buttons-cleanly/179979 "2006-02-24T12:52:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kevinc/32/1079_2.png) [@kevinc](https://forum.kirupa.com/u/kevinc)\
**Post date:** [February 24, 2006, 12:52pm UTC](https://forum.kirupa.com/t/attaching-code-to-multiple-buttons-cleanly/179979/1 "2006-02-24T12:52:03Z")

</div>

Hey all,

Hopefully an easy one.

I have a series of buttons, and I want the same code applied to them all, to handle rollover states etc… Normally I’d do this useing registerClass, but in this case the buttons are added to the stage manually so I can’t.

I could do somehting like this:

```auto
 home_btn.onRelease = news_btn.onRelease = about_btn.onRelease = function() {
    // do something
}

```

But that seems very messy, and I have about 10 buttons, and multiple states.

Any suggestions?

Thanks.
