# {FMX} One function for multiple buttons?

**URL:** <https://forum.kirupa.com/t/fmx-one-function-for-multiple-buttons/68211>\
**Category:** flash\
**Created:** [October 22, 2004, 10:55pm UTC](https://forum.kirupa.com/t/fmx-one-function-for-multiple-buttons/68211 "2004-10-22T22:55:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![justin\_kink](https://avatars.discourse-cdn.com/v4/letter/j/a8b319/32.png) [@justin\_kink](https://forum.kirupa.com/u/justin_kink)\
**Post date:** [October 22, 2004, 10:55pm UTC](https://forum.kirupa.com/t/fmx-one-function-for-multiple-buttons/68211/1 "2004-10-22T22:55:06Z")

</div>

Hiya,

I am building an interactive world map, and for ease of updating am slapping all the functions in a frame on the main timeline.

Say I have a the word “Belgium” with a generic button symbol underneith it (instance name of **Belgium** of course), and also the maps shape of Belgium, as a button labeled, say **Belgium\_Map** , each requiring several functions for rollovers, movement etc, is it possible to simple write one expresion and apply it to both buttons?

Im sure, like most things that one gets stumped on, it is pretty simple, however Im not sure of the syntax…

My code looks something like this:

**buttons.belgium.onPress = function(){**  
map:scale\_target = “250”;  
map:x\_target = “-1050”;  
map:y\_target = “-280”;  
locations:x\_target = “-250”;  
country=“Belgium”  
toptextfade.gotoAndPlay(“fadein”);  
};

So can I apply it to my completly separate button with the path **map.europe.belgium** as well, without having to write out all that crap again for each, when they execute the same things?

Please help, as it will my make my thousands of pages worth of code a bit tidier!

Ill post it as open source once Ive finished aswell, as its pretty cool.

Cheers
