# Finding numerical position of items in an array

**URL:** <https://forum.kirupa.com/t/finding-numerical-position-of-items-in-an-array/227413>\
**Category:** Uncategorized\
**Created:** [May 30, 2007, 3:33am UTC](https://forum.kirupa.com/t/finding-numerical-position-of-items-in-an-array/227413 "2007-05-30T03:33:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![graylensman](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@graylensman](https://forum.kirupa.com/u/graylensman)\
**Post date:** [May 30, 2007, 3:33am UTC](https://forum.kirupa.com/t/finding-numerical-position-of-items-in-an-array/227413/1 "2007-05-30T03:33:44Z")

</div>

What i want to do is to populate a text field with the numerical position of an item in an array. Here’s what I’ve got so far:

an array- call it bArray - which holds references to three button mc’s:  
ActionScript Code:  
[FONT=Courier New][LEFT]bArray=[COLOR=#000000] **new** [/COLOR] [COLOR=#0000FF]Array[/COLOR][COLOR=#000000][[/COLOR]btn1, btn2, btn3[COLOR=#000000]][/COLOR]  
[/LEFT]  
[/FONT]

Then I have a for loop which feeds a variable that numbers each button, and includes rollOver and rollOff functions:  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#0000FF]for[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000] **var** [/COLOR] i=[COLOR=#000080]0[/COLOR]; i\<bArray.[COLOR=#0000FF]length[/COLOR]; i++[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]  
pos=i+[COLOR=#000080]1[/COLOR];  
[COLOR=#808080]_//numberText is a text field in the btn movie clip._[/COLOR]  
bArray[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#000080]numberText[/COLOR].[COLOR=#0000FF]text[/COLOR]=pos;  
[COLOR=#808080]\*//bPos=bArray\*\*[/COLOR]  
bArray[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#0000FF]onRollOver[/COLOR]=rollOverButton;  
bArray[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#0000FF]onRollOut[/COLOR]=rollOutButton;  
[COLOR=#000000]}[/COLOR]  
[/LEFT]  
[/FONT]

Okay, not a problem. But now what I want is this- when you click a button, a text field in another movie clip displays the number of the button just clicked. And I can’t figure out how to derive that value from the array.

Anyone have any helpful clues?
