XML?: Buttons, attachMovie clips, and different timelines

I’m working on a project for a real estate developer. They have a lot plan for a subdivision, with approx. 110 lots. They want a map of this development for their website so that the users can zoom/pan over the development, and be presented with various bits of information about each lot: lot price, status (sold, pending sale, for sale, builder owned), builder name (if applicable), lot size, etc. Additionally, they want each lot color coded somehow for status. Some of this info will change quite often, like price and status. So obviously I’d love to be able to just update an XML file and not have to update the flash document.

Currently, I’ve manually placed “info buttons” in several of the lots and am able to load XML data based on variables set by the button on click. It works like this. I have a button within a movie clip on the main timeline, which opens a window with more detailed information. Actually the button is within several clips, due to the zoom/pan…if it makes any difference, it goes _root.main_map.map.pan.info_button_instance. Anyway, here’s the code on the button:

 ActionScript Code:

 [FONT=Courier New][LEFT][COLOR=#0000ff]on[/COLOR] [COLOR=#000000]([/COLOR]press[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]_root[/COLOR].[COLOR=#0000ff]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"lot35_mc"[/COLOR], [COLOR=#0000ff]_root[/COLOR].[COLOR=#0000ff]getNextHighestDepth[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]lot35_mc[/COLOR].[COLOR=#0000ff]_x[/COLOR]=[COLOR=#000080]20[/COLOR];
[COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]lot35_mc[/COLOR].[COLOR=#0000ff]_y[/COLOR]=[COLOR=#000080]20[/COLOR];
[COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]lot35_mc[/COLOR].[COLOR=#0000ff]attachMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"lotinfo_mc"[/COLOR], [COLOR=#ff0000]"lotinfo"[/COLOR], [COLOR=#000080]1[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#808080]*/*this sets the Child node value to be used by the popup 

for importing XML. “0” is the first child.
This value is different for each button*/*[/COLOR]

[COLOR=#000000]**_global**[/COLOR].[COLOR=#000080]Xlot[/COLOR] = [COLOR=#000080]5[/COLOR];

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

So on press, you get this “pop-up” window, which is just an attached movie clip. It’s created at _root so that it appears at the same size no matter the depth of the zoom on the map. On the first frame of this “lot35” clip, I have the following code to load XML and populate it into the corresponding dynamic text fields:

 ActionScript Code:

 [FONT=Courier New][LEFT][COLOR=#000000]**function**[/COLOR] loadXML[COLOR=#000000]([/COLOR][COLOR=#0000ff]loaded[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]

[COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]

[COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]lot[/COLOR] = [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]firstChild[/COLOR].[COLOR=#0000ff]childNodes[/COLOR][COLOR=#000000][[/COLOR]Xlot[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]price[/COLOR] = [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]firstChild[/COLOR].[COLOR=#0000ff]childNodes[/COLOR][COLOR=#000000][[/COLOR]Xlot[COLOR=#000000]][/COLOR].[COLOR=#0000ff]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]5[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]firstChild[/COLOR].[COLOR=#0000ff]nodeValue[/COLOR];
[COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]terms[/COLOR] = [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]firstChild[/COLOR].[COLOR=#0000ff]childNodes[/COLOR][COLOR=#000000][[/COLOR]Xlot[COLOR=#000000]][/COLOR].[COLOR=#0000ff]childNodes[/COLOR][COLOR=#000000][[/COLOR][COLOR=#000080]6[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#0000ff]firstChild[/COLOR].[COLOR=#0000ff]nodeValue[/COLOR];

lot_txt.[COLOR=#0000ff]text[/COLOR] = [COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]lot[/COLOR];
price_txt.[COLOR=#0000ff]text[/COLOR] = [COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]price[/COLOR];
terms_txt.[COLOR=#0000ff]text[/COLOR] = [COLOR=#0000ff]_root[/COLOR].[COLOR=#000080]terms[/COLOR];
[COLOR=#000000]}[/COLOR] [COLOR=#0000ff]else[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“file not loaded!”[/COLOR][COLOR=#000000])[/COLOR];;

[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];
[/LEFT]
[/FONT]

As it stands now, it works well, but the lots are not color coded for status yet. I’d like to just color code the info buttons, so I could load the buttons dynamically via actionscript from a list of various colored buttons, so that I don’t have to manually update the Flash file when a lot changes status. I just change the XML file from <status>for sale</status> to <status>builder owned, build to suit</status>, and the button color changes from green to red (or whatever), and the info is populated into any necessary text fields. Any tips/pointers on how to do this?

I assume I’ll create an XML object in the first frame of the main timeline and then create empty movieclips via AS, which will load colored buttons from a url listed in the XML doc. If this is correct, how do I attach the AS shown above, to that empty movieclip, which is how the dynamic text fields (lot_txt, price_txt, terms_txt) gets populated with the info from my XML file?

If I load the XML object in the first frame of the main timeline, and I want to access information within that same XML file in an attached movie clip, do i have to create another new XML object, or can I access the one created in the first frame of the main timeline?

Again, i’m pretty much a noob to AS. All of this scripting was pulled from various tutorials or threads on forums and modified through trial and error by me…so i apologize if I’m jumping all over the board. The questions may or may not be related…anyway thanks for the help, and thanks for the great tips I’ve found throughout this site!

rvt