I have an interactive state map, when you mouse over a county certain statistics are displayed.
My client wants to be able to change the statistics. I understand that xml is probably the best way to do this but I have never done anything like this before. Is there a good tutorial or can someone walk me through how to do this?
Thats up to you.. there is no 'real' set way to set-up your XML outside of a few rules.
thats what makes XML so powerful...its flexible..
basically set tings up in an intuitive format/grouping..organizing associated data together
example:
PHP Code:
<states> <state name="Alabama" color="FF0000"> <desc>Some text here saying whatever</desc> </state> <state name="Arizona" color="CC00FF"> <desc>Some text here saying whatever</desc> </state>
</states>
and so on.. for each states..
if you look.. I made a <states></states> node.. and inside those tags.. I grouped simialr data (<state></state> tags)...
inside each <state> tag.. I put data associated with that state..
the tag names are what you want them to be.. but you need to open & close them like an HTML tag..
Ok, I think I'm starting to get it. I've attached a screen shot of the file I'm working on; when you hover over a county the information is displayed. How do I display the ages and pregnancy rate information in the xml file?
Also do I need to list the counties in alphabetical order?
1.) you need to have all those 'counties' be individual buttons/movieclips.
2.) you would need an XML file that has all the data you want to display/add.. (what is it?, JUST ages and pregnancy info?)
3.) you would need to load, then loop through this XML file and add the data to each clip (county) on the map...
4.) while you are looping through the XML data and assigning the specific data to each clip...you can also assign rollOver/Out actions.. to display a pop-up or whatever and display the info.
what do you mean a certain way? you can do whatever you want with the data...
the XML schema/layout comes into play if you have more than one piece of the data for the same thing.. looking at the image you linked to..
will each county have the same breakdown for ages? 3 age categories?
when you have the similar data for an item..it is best to group them together in a parent node/element.. this makes it EASIER in flash to loop through that specific node and grab only that data..
keep in mind XML is nothing more than an 'organized' text file.. its just a way to bring in data into your flash movie.. nothing more.. you still have to code things on the flash side to handle that data and display how & where you see fit.
As you hover each county that counties information is displayed. I just need to make sure that the information for each county displays consistently (like the screen shot shows)
In answer to your question: will each county have the same breakdown for ages? 3 age categories? Yes.
consistently...?? as in all the time? or visible until you rollover a new 'county'?
I suggest my last XML layout/schema then...
I would also suggest you name each clip(county) the same as you use in the county name in the XML field..so you can easily target (find) the clip on the stage and assign data to it..
I dont need the .fla (I dont wanna do the project for ya!) LOL
Im just trying to help you understand so you can do whatever works best for you.
so each age bracket/range is the same for EACH/EVERY county...
and only the Prego. Rates change?
if so then you dont need the age attribute in the XML file..
basically you'll load the XML file..and pick (parse) out the data you need.. you will need to decide how & where you want to put this data.. will you have 3 separate text fields for the rates of each county? 1 text field that you just format with line spaces?..etc
That is correct, the age ranges are the same for each county only the prego rates will change. With that being said should my xml file look like this?:
1.) populate the XML file with all your counties (or whatever ones you need to add data to)
2.) name all the movieClip/counties on the stage to match the names in the XML file
3.) add a few lines of code that when you rollOver the movieClip/county (already there)..the data that is nested inside each clip gets display in a text field..or 3 separate textfields..(not already there)
when you rollover the clips you will see the data trace out already..