# Attach an actionscript to multiple buttons at once

**URL:** <https://forum.kirupa.com/t/attach-an-actionscript-to-multiple-buttons-at-once/118261>\
**Category:** Uncategorized\
**Created:** [August 4, 2004, 2:26am UTC](https://forum.kirupa.com/t/attach-an-actionscript-to-multiple-buttons-at-once/118261 "2004-08-04T02:26:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alicethomas78](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@alicethomas78](https://forum.kirupa.com/u/alicethomas78)\
**Post date:** [August 4, 2004, 2:26am UTC](https://forum.kirupa.com/t/attach-an-actionscript-to-multiple-buttons-at-once/118261/1 "2004-08-04T02:26:02Z")

</div>

I’m trying to find the way to attach the same actionscript to multiple  
buttons(over 100 buttons) at one time, instead of copying and pasting  
the actionscript in every frame. I have over 100 buttons as a seperate object in the library. In timeline, there are 100 keyframe, that each frame contains one button. Each instance is from one button. I don’t want to write a same actionscript in for every button object. Is there anyway to get  
around that?

thank you in advance,  
Nu

---

<div class="post-metadata">

**Author:** ![e\_s\_x\_s](https://avatars.discourse-cdn.com/v4/letter/e/f9ae1b/32.png) [@e\_s\_x\_s](https://forum.kirupa.com/u/e_s_x_s)\
**Post date:** [August 4, 2004, 9:12am UTC](https://forum.kirupa.com/t/attach-an-actionscript-to-multiple-buttons-at-once/118261/2 "2004-08-04T09:12:14Z")

</div>

make your button names like myButton0,myButton1,myButton2,myButton3…  
and than make a for loop like:

[AS]  
for(i=0;i\<100;i++){  
\_root[“myButton”+i].onRelease = function(){  
// YOUR ACTINSCRIPT 😉  
}  
}  
[/AS]

---

<div class="post-metadata">

**Author:** ![alicethomas78](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@alicethomas78](https://forum.kirupa.com/u/alicethomas78)\
**Post date:** [August 5, 2004, 8:35am UTC](https://forum.kirupa.com/t/attach-an-actionscript-to-multiple-buttons-at-once/118261/3 "2004-08-05T08:35:10Z")

</div>

Thank you very much for your answer.

> [@e.s.x.s](#):
>
> make your button names like myButton0,myButton1,myButton2,myButton3…  
> and than make a for loop like:
> 
> [AS]  
> for(i=0;i\<100;i++){  
> \_root[“myButton”+i].onRelease = function(){  
> // YOUR ACTINSCRIPT 😉  
> }  
> }  
> [/AS]
