I'm testing a small proof-of-concept, to verify that I can indeed load variables into Flash that will be processed through a custom function. The function should check the arrays for compatible variables and assign color to the appropriate movieclip. I know, a visual or code view would better relay my concept than words.
Unfortunately, I can't get this to work yet. I haven't spent too long on it or tried too many times... so back to the "code" board. I do have decent notes on paper to explain what it is I want to accomplish, it's just a matter of translating it into arrays, loops, and if statements.
Okay, here's the first semi-success: dynamicColorSwitch2_readVar. The two earlier problems were that my array names didn't match up in the code and I put "=" instead of "==" in the if statement condition.
This is not a success because if my loop worked correctly, the houses would be different colors. As it is, it looks like my conditional is crap and just assigning all the color variables to all the houses -- no compatibility check like mentioned above.
Using the "trace()" indicates that my conditional isn't catching the value after "==".
Eureka! I have it! See dynamicColorSwitch2_readVar2.
Another careless coding mistake. Since I'm loading values with arrays, I need to enclose all the values with quotation marks. This is something I always get stumped on! I'll have to watch for these tripping points later....
Here's the code:
var county = ["","/house1","/house2","/house3","/house4"];
var district = ["","NE","NW","SE","SW"];
var color = ["",0x7a287a,0x0066cc,0xff0099,0xffff00];
var county_district = ["","NE","NE","SW","SE"];
var p = 0;
while (p<county.length) {
}
var district = ["","NE","NW","SE","SW"];
var color = ["",0x7a287a,0x0066cc,0xff0099,0xffff00];
var county_district = ["","NE","NE","SW","SE"];
var p = 0;
while (p<county.length) {
var q = 0;
while (q<district.length) {
if (county_district[p] == district[q]) {
}
q++;
}
trace (county[p]);
p++;
while (q<district.length) {
if (county_district[p] == district[q]) {
county_color=color[q];
set_county_color = new Color(county[p]);
set_county_color.setRGB(county_color);
trace (district[q]);
set_county_color = new Color(county[p]);
set_county_color.setRGB(county_color);
trace (district[q]);
}
q++;
}
trace (county[p]);
p++;
}
Putting it together:
Here is the first iteration of the Flash map. This shows a few dynamically colored counties, based on Extension district. ga_flashmapTest
I've started an Excel spreadsheet to manage the data. I suppose at some point this could be exchanged for a database feed.
Next steps:
- turning all those Georgia counties into movieclips
- setting up control through buttons
- adding another dataset to toggle between values

0 comments:
Post a Comment