Wednesday, March 28, 2007

Importing external data

I've imported external data that my coworker was kind enough to glean from a company database today. I feel better working with real information than trying to "imagine" what my data might look like. So, I have a huge set of arrays in this file: countyData.as. Essentially, I've collected a list of county ids for a large number of topics. At the bottom of this AS file, I have all of the topics listed in a master array.

So, what can I do with this kind of information? Eventually, I'll use this info to populate specific items in my GA Flash Map. Most likely this will be some sort of button mechanism that, when chosen, will highlight the associated counties on the map.

For now, I'm back to testing, to see if I can get my functions working correctly. You can see my test file here: variableTest.html.

The actionscript on this file first imports "countyData.as" -- my external data. Then I load a function "showOutput" that will populate a hidden output area when a text button is selected.
#include "countyData.as"
function showOutput(b) {
outputArea.htmlText = b;
}

I populate the contentArea (in the blue box) with HTML formatted text here. This is running through my arrays in the external file and listing out the first item in each sub-array of "topic". In addition, this code ignores any arrays that do not have counties associated with it.
myText ="";
p=0;
while (p<topic.length) {
q = topic[p];
if (q.length>1){ // checks for topics with county data
myText = myText + "<u><a href='asfunction:showOutput," + q + "'>" + q[0] + "</a></u><br>";
}
p++;
}
contentArea.htmlText = myText;
trace(myText);

The HTML formatting allows me to easily add a function as a link. I find this is easier to control and predict than creating buttons on the fly (like attempt last week with the multiple choice file). So, the link calls the function "showOutput" and loads the text from "q" into my hidden output area.

This script works my scroll bars.
contentArea.scroll = 0;
if (contentArea.maxscroll<=1) {
myScrollBar._visible = false;
} else {
myScrollBar._visible = true;
}

My next step involves cleaning up the text that is associated with my "showOutput" function. Essentially, I want to only pass the county IDs, since these will be used to color the map.

More to come!

0 comments: