Local Connection and Arrays

Hello all,

I have a project that I am working on that consists of a topline navigation that sends local connection commands to a module. Everything is working fine, but I’d like to generate the local connection functions using and XML file and an array. Here’s what I have so far that works.

 ActionScript Code:
 [FONT=Courier New][LEFT][COLOR=#808080]*/////////Located in top_navigation.fla*[/COLOR]

Actions.[COLOR=#000080]homeFunction[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
outgoing_lc = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]LocalConnection[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#808080]//send the contents of the text field [/COLOR]
[COLOR=#808080]
//using the send() method
[/COLOR]
outgoing_lc.[COLOR=#0000ff]send[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“lc_navigation”[/COLOR], [COLOR=#ff0000]“homeFunction”[/COLOR], whichCat.[COLOR=#0000ff]text[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#808080]//delete the local connection now that the [/COLOR]
[COLOR=#808080]
//message has been sent
[/COLOR]
[COLOR=#0000ff]delete[/COLOR] outgoing_lc;

[COLOR=#000000]}[/COLOR];

[COLOR=#808080]/////////Located in main_module.fla[/COLOR]

incoming_lc = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]LocalConnection[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#808080]//start the connection[/COLOR]
incoming_lc.[COLOR=#000080]homeFunction[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
copyMC = [COLOR=#ff0000]“home_text”[/COLOR]; [COLOR=#808080]//sets the variable[/COLOR]
textloadMCCOLOR=#000000[/COLOR]; [COLOR=#808080]//runs the function[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#808080]//further functions inserted here[/COLOR]
incoming_lc.[COLOR=#0000ff]connect[/COLOR]COLOR=#000000[/COLOR]; [COLOR=#808080]*//final incoming connection *[/COLOR]

[/LEFT]
[/FONT]

There are actually too connections being set up as i am loading two swf’s in the main module - one of the right and one on the left but I have simplified it here a bit. Because I need to keep adding/editing various menu items I’d likek to streamline the process and not have so much code in my swf. Seems like an XML set up like this:

 <?xml version="1.0"?>
<menumain>
    <menu name="homeFunction" left="home_left" right="home_text"></menu>
</menumain>

Is the way to do it. So I started out just trying to change the function from homeFunction to this:

 ActionScript Code:
 [FONT=Courier New][LEFT][COLOR=#000000]**var**[/COLOR] xmlArr:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000][[/COLOR][COLOR=#ff0000]"homeFunction"[/COLOR], [COLOR=#ff0000]"whenFunction"[/COLOR][COLOR=#000000]][/COLOR];

[COLOR=#000000]var[/COLOR] xmlValue = xmlArr[COLOR=#000000][[/COLOR][COLOR=#000080]0[/COLOR][COLOR=#000000]][/COLOR];

[COLOR=#808080]/////////Located in top_navigation.fla[/COLOR]
Actions.[COLOR=#000080]xmlValue[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
outgoing_lc = [COLOR=#000000]new[/COLOR] [COLOR=#0000ff]LocalConnection[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#808080]//send the contents of the text field [/COLOR]
[COLOR=#808080]
//using the send() method
[/COLOR]
outgoing_lc.[COLOR=#0000ff]send[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“lc_navigation”[/COLOR], xmlValue, whichCat.[COLOR=#0000ff]text[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#808080]//delete the local connection now that the [/COLOR]
[COLOR=#808080]
//message has been sent
[/COLOR]
[COLOR=#0000ff]delete[/COLOR] outgoing_lc;

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

etc. So basically changing anywhere I have homeFunction to the variable which is define by the array. So problem numer one is that for some reason, in this particular FLA array seem to keep returning an undefined value. Very odd as the same array set up in a new FLA works fine. I’ve moved it to the top of the code and all around but still underfined. What can screw that up? Anyway, even doing something as simple as just defining a variable:

xmlValue = “homeFunction”;

doesn’t work. So how can I do this and in the long run save myself lots of typing. Let me know I need to clarify anything.

-Patrick