Skip to main content
Serendipitous_future15B9
Known Participant
July 28, 2010
Answered

Make string of MCs invisible/visible...

  • July 28, 2010
  • 1 reply
  • 870 views

I have a map of states state when a particular state is clicked on, the fla centers on and zooms to that state.  When you click on a state a unique ID is pulled from an xml.  Using this ID, I can then call all the counties that are part of this state through the county's xml which is also loaded on my stage.

For example if I click on Arizona, it zooms and I get a trace of all the instance names of the counties within Arizona.

//call all instance names of Arizona counties

cldcnfips=(cntXml.Records.Record.(STATE_FIPS==cldstfips).afips.children());
trace(cldcnfips);

//The trace looks like this

a04001a04003a04005a04007a04009a04011a04012a04013a04015a04017a04019a04021a04023a04025a04027

//where "a" is the first character in each county's instance name

One of my first lines of code makes my counties invisible.

//dont show the counties yet
this.cnt.all_cnt.visible=false;

What I'd like to do is make just the called state's counties visible on zoom.

Since I've created a var which is a string of the counties I am interested in, can I specify that just those counties become visible?  I've tried this code but it does not work

this.cnt.all_cnt[cldcnfips].visible=true

I am worried that the string I am pulling as a reference for those counties (cldcnfips) might not work for calling those instances.

Does anyone have any suggestions or insights?

This topic has been closed for replies.
Correct answer kglad

use:

for(var i:uint=0;i<cldnfips.length();i++){

this.cnt.all_cnt[cldcnfips].visible=true

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
July 28, 2010

use:

for(var i:uint=0;i<cldnfips.length();i++){

this.cnt.all_cnt[cldcnfips].visible=true

}

Serendipitous_future15B9
Known Participant
July 28, 2010

I added your suggested code to a buttont that I am using to test functionality...

     tstbut.addEventListener(MouseEvent.CLICK,tstact);
     function tstact(e:Event){
          for(var i:uint=0;i<cldcnfips.length();i++){
          this.cnt.all_cnt[cldcnfips].visible=true
                                           }
                    }          

Getting an error message that I've not seen before.

TypeError: Error #1010: A term is undefined and has no properties at uscounties_west_7_28_fla::MainTimeline/frame1()

Serendipitous_future15B9
Known Participant
July 28, 2010

Ok gottit...

I decied to put the counties under the states, leave them visible and then just make the called state invisible..

also... flash did not like the

this

before the visible command