# Convert MC Button Code to Reusable Function?

**URL:** <https://forum.kirupa.com/t/convert-mc-button-code-to-reusable-function/210053>\
**Category:** flash\
**Created:** [December 14, 2006, 3:16pm UTC](https://forum.kirupa.com/t/convert-mc-button-code-to-reusable-function/210053 "2006-12-14T15:16:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![matm00](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/matm00/32/2487_2.png) [@matm00](https://forum.kirupa.com/u/matm00)\
**Post date:** [December 14, 2006, 3:16pm UTC](https://forum.kirupa.com/t/convert-mc-button-code-to-reusable-function/210053/1 "2006-12-14T15:16:25Z")

</div>

Basically I’m using the code below to change the colour of the text in a movie clip that I’m using as a button. This works fine, but I have 8 buttons in my navigation and at the moment have to duplicate this code for each one. Can someone help me turn the colour change code into a function that I can reuse?

```auto
var up = "0xC5B9B3";
var over = "0xC6006F";

_root.nav.button_1.onRollOver = function() {
    _root.nav.button_1.dyntext_1.textColor = (over);
}
_root.nav.button_1.onRollOut = function() {
    _root.nav.button_1.dyntext_1.textColor = (up);
}

```
