# Toggle button

**URL:** https://forum.kirupa.com/t/toggle-button/272757
**Category:** Uncategorized
**Created:** [October 8, 2008, 9:10am UTC](https://forum.kirupa.com/t/toggle-button/272757 "2008-10-08T09:10:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tobycraftse](https://avatars.discourse-cdn.com/v4/letter/t/7bcc69/32.png) [@tobycraftse](https://forum.kirupa.com/u/tobycraftse)
#### Post date: [October 8, 2008, 9:10am UTC](https://forum.kirupa.com/t/toggle-button/272757/1 "2008-10-08T09:10:26Z")

</div>

I have 5 button with ID = but1, but2, but3, but4, but5

I want to loop the buttons and create a click event to toggle the alpha of the buttons.

but the following code doesn’t work when looping each of the button IDs.

how can I loop each button and set a Key event toggle?

```auto

functALL = new Array ( but1, but2, but3, but4, but5 );

for ( i=0; i < functALL.length; i++){
    functALL*.onRelease = function (){
        if (functALL*._alpha = 40 ){
            functALL*._alpha = 100;
        } else {
            functALL*._alpha = 40;
        }
    }
}

```
