# For loops and buttons and XML and CONFUSION!

**URL:** <https://forum.kirupa.com/t/for-loops-and-buttons-and-xml-and-confusion/211129>\
**Category:** Uncategorized\
**Created:** [December 27, 2006, 6:41pm UTC](https://forum.kirupa.com/t/for-loops-and-buttons-and-xml-and-confusion/211129 "2006-12-27T18:41:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fasterthanlight](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fasterthanlight](https://forum.kirupa.com/u/fasterthanlight)\
**Post date:** [December 27, 2006, 6:41pm UTC](https://forum.kirupa.com/t/for-loops-and-buttons-and-xml-and-confusion/211129/1 "2006-12-27T18:41:33Z")

</div>

**[size=5]New Problem:[/size]**  
Read Post #5

> **[For loops and buttons and XML and CONFUSION!!!](https://www.kirupa.com/forum/showthread.php?245137-For-loops-and-buttons-and-XML-and-CONFUSION!!!&s=b1f60db8dae0e0525e6b40522f346212&p=2029968#post2029968)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

Hey guys, I’m working on a dynamic scrolling logo display, basically when the user rolls over one of the constantly scrolling logos, text appears beneath in a text field.

I have it set up like so:

**Root Timeline:**  
container\_mc  
…logoContainer\_mc (which gets duplicated and placed next to the one before it)  
…logo\_mc (where the logos are loaded into)  
…logoTitle\_txt (the textfield that displays the company name)  
…logo\_btn (the invisible button that you click to visit the homepage of that company)

So within container\_mc, logoContainer\_mc is duplicated and populated with images/text from an XML file.  
\*\*  
My Code:  
\*\* ActionScript Code:  
[FONT=Courier New][LEFT]title\_a = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];  
xmlData = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000FF]XML[/COLOR]COLOR=#000000[/COLOR];  
xmlData.[COLOR=#0000FF]ignoreWhite[/COLOR] = [COLOR=#000000] **true** [/COLOR];  
xmlData.[COLOR=#0000FF]onLoad[/COLOR] = loadXML;  
xmlData.[COLOR=#0000FF]load[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#000000] **var** [/COLOR] imageLoader:[COLOR=#0000FF]MovieClipLoader[/COLOR] = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000FF]MovieClipLoader[/COLOR]COLOR=#000000[/COLOR];  
imageLoader.[COLOR=#0000FF]addListener[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#000000] **function** [/COLOR] loadXMLCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#0000FF]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#0000FF]xmlNode[/COLOR] = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]firstChild[/COLOR];  
total = [COLOR=#0000FF]xmlNode[/COLOR].[COLOR=#0000FF]childNodes[/COLOR].[COLOR=#0000FF]length[/COLOR];  
[COLOR=#0000FF]for[/COLOR] [COLOR=#000000]([/COLOR]i=[COLOR=#000080]0[/COLOR]; i\<total; i++[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]  
title\_a[COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR] = [COLOR=#0000FF]xmlNode[/COLOR].[COLOR=#0000FF]childNodes[/COLOR][COLOR=#000000][[/COLOR]i[COLOR=#000000]][/COLOR].[COLOR=#0000FF]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000FF]firstChild[/COLOR].[COLOR=#0000FF]nodeValue[/COLOR];  
[COLOR=#0000FF]\_root[/COLOR].[COLOR=#000080]container\_mc[/COLOR].[COLOR=#000080]logoContainer\_mc[/COLOR].[COLOR=#0000FF]duplicateMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000][[/COLOR][COLOR=#FF0000]“logoContainer”[/COLOR]+i[COLOR=#000000]][/COLOR], i, [COLOR=#000000]{[/COLOR][COLOR=#0000FF]\_x[/COLOR]:COLOR=#000000[/COLOR]_[COLOR=#000080]162[/COLOR], [COLOR=#0000FF]\_y[/COLOR]:[COLOR=#000080]0[/COLOR][COLOR=#000000]}[/COLOR][COLOR=#000000])[/COLOR];  
imageLoader.[COLOR=#0000FF]loadClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]“logos/”[/COLOR]+i+[COLOR=#FF0000]".jpg"[/COLOR], [COLOR=#0000FF]\_root[/COLOR].[COLOR=#000080]container\_mc[/COLOR][COLOR=#000000][[/COLOR][COLOR=#FF0000]“logoContainer”[/COLOR]+i[COLOR=#000000]][/COLOR].[COLOR=#000080]logo\_mc[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#0000FF]\_root[/COLOR].[COLOR=#000080]container\_mc[/COLOR][COLOR=#000000][[/COLOR][COLOR=#FF0000]“logoContainer”[/COLOR]+i[COLOR=#000000]][/COLOR].[COLOR=#000080]logo\_btn[/COLOR].[COLOR=#0000FF]onRollOver[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#0000FF]trace[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#808080]_//Here’s the problem, this is returning undefined, when it shouldn’t._[/COLOR]  
[COLOR=#0000FF]\_root[/COLOR].[COLOR=#000080]container\_mc[/COLOR][COLOR=#000000][[/COLOR][COLOR=#FF0000]“logoContainer”[/COLOR]+i[COLOR=#000000]][/COLOR].[COLOR=#000080]logoTitle\_txt[/COLOR].[COLOR=#0000FF]text[/COLOR] = title\_a[COLOR=#000000][[/COLOR]i-[COLOR=#000080]1[/COLOR][COLOR=#000000]][/COLOR]; [COLOR=#808080]_//This should work but doesn’t.\*[/COLOR]  
[COLOR=#000000]}[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR] [COLOR=#0000FF]else[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#0000FF]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]“XML ERROR”[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[/LEFT]  
[/FONT]

\*Note: the comment “Here’s the problem”

It’s pretty straightforward, but there is some path error I can’t figure out, i need to be able to assign the textfield that corresponds to the button the user is rolling over the information from the title\_a[] array, but its returning undefined.

Help!!
