we developed a dynamic map that shows what states use the client's products - the code below pulls the data from the db, then shades the map and writes state names
as a standalone swf, it works like a charm - but of course, client now wants to change the page structure so that this swf will need to be loaded into an existing swf 'container' - which throws a big-ass wrench into the mix -
i've been slamming my head against the desk for hours and havent come up with a working solution - anybody know any relatively painless solutions?
any help greatly appeciated
// Incoming variables: // states: Array of state abbrevs. currently launched // schoolYear: The Current School Year // modules: Module Count //
var stateObj:Object = new Object(); stateObj.states = this.states.split(",").sort(); var numStates:Number = stateObj.states.length;
var textAssembly = " launched more than "+formatNumber(modules)+" modules in "+numStates+" states for the "+schoolYear+" school year."; stHeader.html = true; stHeader.htmlText = textAssembly;
//////////////////////////////////// // AUTORUN // ////////////
setStateMap(); popStateList();
//////////////////////////////////// // FUNCTIONS // ////////////// function formatNumber(num){ numStr = num.toString(); if(numStr.length > 6){ aNum = numStr.substr((numStr.length - 3),3); bNum = numStr.substr((numStr.length - 6),3); cNum = numStr.substr(0,(numStr.length - 6)); dNum = cNum+","+bNum+","+aNum; return dNum; } else if(numStr.length > 3){ aNum = numStr.substr((numStr.length - 3),3); bNum = numStr.substr(0,(numStr.length - 3)); cNum = bNum+","+aNum return cNum; } else{ return num; } }
function changeCol(mc) {
var hasSchool:Color = new Color(mc);
//hasSchool.setRGB(0xD22513);
hasSchool.setRGB(0xB1C3D9);
}
function setStateMap(){ num = stateObj.states.length; for(i=0;i<num;i++){ changeCol(this[stateObj.states[i]]); } }
function popStateList(){ num = stateObj.states.length; for(i=0;i<num;i++){ addMe = getState(stateObj.states[i]); stateList.text += " - "+ addMe + "\r"; } }
function getState(st){ if (st == "AL"){ return "Alabama"; } else if (st == "AK"){ return "Alaska"; } else if (st == "AZ"){ return "Arizona"; } else if (st == "AR"){ return "Arkansas"; } else if (st == "CA"){ return "California"; } else if (st == "CO"){ return "Colorado"; } else if (st == "CT"){ return "Connecticut"; } else { return ">> State Error"; } }
stop();
load the self-contained swf into a Movie in the design and the functions will be accessible by the parent with:
var _state:String = instanceName.getState(CA); or in AS2 level 100 with: var _state:String = _level100.getState(CA);
I hear your pain though. Most of my fine work ends up being such a hack of stuff in the end because the changes come the day before the presentation an then more changes come back from the presentation and then...... screw it....this is what they get.
"It works, doesn't it?" is always my answer
thx again Storm! 
maybe you can help me out with this one -
so we grab the states that use the products from the db and it spits out an array such as AL,DC,NY,TN,KS,MN,MO,GA,ND,AR,AK ... - but say i want to only display one 'featured' state every time the page loads?
how would i randomly pick one state from that array (in order to tell it to play the corresponding MC?)