# XML and arrays - matching data to button (Flash 8)

**URL:** <https://forum.kirupa.com/t/xml-and-arrays-matching-data-to-button-flash-8/199602>\
**Category:** flash\
**Created:** [September 4, 2006, 12:04pm UTC](https://forum.kirupa.com/t/xml-and-arrays-matching-data-to-button-flash-8/199602 "2006-09-04T12:04:45Z")\
**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:** [September 4, 2006, 12:04pm UTC](https://forum.kirupa.com/t/xml-and-arrays-matching-data-to-button-flash-8/199602/1 "2006-09-04T12:04:45Z")

</div>

Greetings!

I’ve got an XML document that I’m loading into Flash. Based on the data in the XML document, I’m dynamically creating buttons for a menu, using a “for” loop and an array. this works fine - no problem here.  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#808080]_//where buttonHolder is a movie clip to hold the button instances_[/COLOR]  
[COLOR=#808080]_//btnCount and btnYspace distribute the instances_[/COLOR]  
btnArray = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000FF]Array[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#0000FF]for[/COLOR] [COLOR=#000000]([/COLOR]i=[COLOR=#000080]0[/COLOR]; i\<this.[COLOR=#0000FF]firstChild[/COLOR].[COLOR=#0000FF]childNodes[/COLOR].[COLOR=#0000FF]length[/COLOR]; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]

```
        buttonHolder.[COLOR=#0000FF]attachMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]"theBtn"[/COLOR], [COLOR=#FF0000]"theBtn"[/COLOR]+i, i[COLOR=#000000])[/COLOR];
        btnArray[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = buttonHolder[COLOR=#000000][[/COLOR][COLOR=#FF0000]"theBtn"[/COLOR]+i[COLOR=#000000]][/COLOR];
        btnArray[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#0000FF]_y[/COLOR] = btnCount*btnYspace;
        btnCount++;

```

[COLOR=#000000]}[/COLOR]  
[/LEFT]  
[/FONT]

What I want to happen is this: When you press a particular button, text is loaded into dynamic text boxes. This data needs to correspond to the button instance pressed. So, if btnArray\* instance is button 3, I need to load all the XML data for button 3.

I’ve placed the additional XML data in another array. I can trace that fine, so I know all the data works. The problem is linking the two. How can I determine which item in the btnArray is pressed, and load the appropriate information from the data Array?

I tell you, I’m stumped!
