Hi All
I have a map of the US made up of 50 state instances. These instances are all MCs and have been name according to the 2 letter state abbreviation.
I am pulling some data from Flash Remoting. The problem is when i try to insert a new color based on the value pulled for a state, some state MCs will change colors and others won’t.
Now i thought perhaps it is a problem with the fact that movies aren’t loaded yet, but these movies are all already on the scene.
I have attached the code below:
[AS]
//Code that loops through results and assigns a color value
function initVariables(){
memberLevel1 = “0x072CA9”;
memberLevel2 = “0x2353F5”;
memberLevel3 = “0x608EFB”;
memberLevel4 = “0x00CCFF”;
memberLevel5 = “0xB9CDFD”;
moneyLevel1 = "0x006600";
moneyLevel2 = "0x009900";
moneyLevel3 = "0x00CC00";
moneyLevel4 = "0x00FF00";
moneyLevel5 = "0x66FF99";
moneyLev1 = "10000000";
moneyLev2 = "1000000";
moneyLev3 = "500000";
moneyLev4 = "100000";
moneyLev5 = "100000";
}
function prepareLegend(map) {
initVariables();
if (map == "usMap"){
//trace("doIt");
_root.usMapTitle.text = "Members by State";
_root.legend1.text = "> 15,000 Members";
_root.legend2.text = "> 7,500 Members";
_root.legend3.text = "> 2,000 Members";
_root.legend4.text = "> 1000 Members";
_root.legend5.text = "< 1000 Members";
for (n=1; n<=5 ;n++){
var newColor = new Color(eval("cl"+n));
newColor.setRGB(eval("memberLevel"+n));
}
} else if (map == "usMoney") {
_root.usMapTitle.text = "Gross Winning by State";
_root.legend1.text = "> $10,000,000";
_root.legend2.text = "> $1,000,000";
_root.legend3.text = "> $500,000";
_root.legend4.text = "> $100,000";
_root.legend5.text = "< $100,000";
for (n=1; n<=5 ;n++){
var newColor = new Color(eval("cl"+n));
newColor.setRGB(eval("moneyLevel"+n));
}
}
}
function getMoney_Result(money){
trace(“I am back”);
localStates = money;
prepareLegend(“usMoney”);
setInterval(populate, 3000, "lala");
}
function populate() {
trace(localStates.items.length);
for (i=0; i<localStates.items.length; i++){
//trace(localStates.items*.state_abv);
//trace(localStates.items*.num);
if (localStates.items*.amount >= moneyLev1){
var newColor = new Color(localStates.items*.state_abv);
newColor.setRGB(moneyLevel1);
} else if (localStates.items*.amount >= moneyLev2) {
var newColor2 = new Color(localStates.items*.state_abv);
newColor2.setRGB(moneyLevel2);
} else if (localStates.items*.amount >= moneyLev3) {
trace("$500,000" + localStates.items*.state_abv);
var newColor3 = new Color(localStates.items*.state_abv);
newColor3.setRGB(moneyLevel3);
} else if (localStates.items*.amount >= moneyLev4) {
var newColor4 = new Color(localStates.items*.state_abv);
newColor4.setRGB(moneyLevel4);
} else if (localStates.items*.amount < moneyLev5) {
var newColor5 = new Color(localStates.items*.state_abv);
newColor5.setRGB(moneyLevel5);
}
}
}
[/AS]