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!