Multiple buttons with similar actions

hi everyone,

i have a problem with buttons in Flash. I have about 20 buttons on the stage and i want them all to have nearly the same AS.
Example:

button1:
on (release){
select = 1;
gotoAndStop(1);
}

button2:
on (release){
select = 2;
gotoAndStop(1);
}

Is there a way of changing this into 1 piece of code on the timeline, something like:

_root[“button”+a].onRelease=function(){
select = a;
gotoAndStop(1);
}

I hope this can be done, so i won’t have to update 20 buttons if something changes.

Thanks.

me.thankYou();

[FONT=Courier New][/FONT]