# Retrieving instance name of buttons from array and change it stae

**URL:** <https://forum.kirupa.com/t/retrieving-instance-name-of-buttons-from-array-and-change-it-stae/303244>\
**Category:** Uncategorized\
**Created:** [January 17, 2010, 3:18pm UTC](https://forum.kirupa.com/t/retrieving-instance-name-of-buttons-from-array-and-change-it-stae/303244 "2010-01-17T15:18:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![simplyJohn](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@simplyJohn](https://forum.kirupa.com/u/simplyJohn)\
**Post date:** [January 17, 2010, 3:18pm UTC](https://forum.kirupa.com/t/retrieving-instance-name-of-buttons-from-array-and-change-it-stae/303244/1 "2010-01-17T15:18:22Z")

</div>

Hey guys!  
i am newy to AS3, i have four buttons instances (of same object) on the stage (first\_btn,second\_btn…fourth\_btn). i created an array (btnArray) and stored buttons instance name in it. After this i created an timer event to cycle through all the button for certain interval.

the code is:-

function timerListener(e:TimerEvent): void {

```
while ( i &lt;= (btnArray.length - 1)) {
       trace(btnArray*);
       i++;
       if (i==4) {
           //first_btn.upState = first_btn.overState;
           i=0;
           }
       break;
       //btnArray*.upState = btnArray*.overState;
       
       }
    }

```

Now the problem is, I want to change the button state from upState to overState  
but this cmd , btnArray\*.upState = btnArray\*.overstate is giving an error, however whenever i use instance name directly  
first\_btn.upState = first\_btn.overState it is working fine.

I am trying to structure my project such that if i need to add more buttons then i just need to add their instance name in the array, But i am unable to figure out how to use array index notation to specify instance name in AS3… Kindly reply…
