# How to avoid repeating the same function for various buttons?

**URL:** <https://forum.kirupa.com/t/how-to-avoid-repeating-the-same-function-for-various-buttons/328093>\
**Category:** flash\
**Created:** [April 18, 2012, 7:10pm UTC](https://forum.kirupa.com/t/how-to-avoid-repeating-the-same-function-for-various-buttons/328093 "2012-04-18T19:10:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![learner\_7n](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@learner\_7n](https://forum.kirupa.com/u/learner_7n)\
**Post date:** [April 18, 2012, 7:10pm UTC](https://forum.kirupa.com/t/how-to-avoid-repeating-the-same-function-for-various-buttons/328093/1 "2012-04-18T19:10:48Z")

</div>

Hi,

I have the following code for the button over/out effect. It is nice but instead of writing the same code for function for each button (I have 15 buttons), how to shorted the code by modifying it?

```auto
Button1_mc.addEventListener(MouseEvent.MOUSE_OVER, navOver);
Button1_mc.addEventListener(MouseEvent.MOUSE_OUT, navOut);

function navOver(e:MouseEvent):void {
TweenMax.to(Button1_mc, .5, {glowFilter:{color:0xFFFFFF, alpha:1, blurX:20, blurY:20, strength:1, quality:2}});
}

function navOut(e:MouseEvent):void {
TweenMax.to(Button1_mc, .5, {glowFilter:{color:0xFFFFFF, alpha:0, blurX:0, blurY:0, strength:1, quality:2}});

    TweenMax.to(e.target, .5, {tint:null});
}

```
