Skip to main content
Known Participant
August 3, 2011
Answered

Filter issue with interactive map

  • August 3, 2011
  • 1 reply
  • 985 views

I've created an interactive map with filters for the map points using if/else visible statements.

The problem is that some of the points belong to more than one filter (i.e., health, education related, etc.). So the filters act properly when selected and deselected one at a time but don't show the proper map points if more than one filter is selected.

Any help would be greatly appreciated! Thank you!

This topic has been closed for replies.
Correct answer kglad

I have the checkboxes set up as buttons, but I'll change them to movieclips. It was a simple visible=true or false with an if/else statement but I can see why it wasn't working. I'm going to try your code and see if I can get it to work, though I won't be able to get to it today.

Thank you!!!! You've been great. I'll let you know how it goes.


to create a movieclip button:

create a new movieclip.  copy the up-frame from the button and paste that frame into frame 1 of your movieclip.  label that frame "unchecked".  create an empty keyframe (eg, at frame 5), label it "checked" and paste the ...

actually, how could you create a checked button frame?  that wouldn't work with a simple button.

anyway, add your graphics with the check mark to the "checked" movieclip frame.

1 reply

kglad
Community Expert
Community Expert
August 3, 2011

what's your setup?  do you have an array for objects for each filter?

seansashaAuthor
Known Participant
August 4, 2011

It's not set up as an array. Following is an example. I think the issue is (there are other filters) that btnColorado could be true for both Education and Health while others are only true for Education.

Education_btn.addEventListener (MouseEvent.CLICK,showEducation);

function showEducation (evt:MouseEvent) {
   
    if (Education_displayed.visible == true)
    {
    Education_displayed.visible = false;
    btnColorado.visible = false
    btnTexas.visible = false
   
} else {

  Education_displayed.visible = true;
    btnColorado.visible = true  

    btnTexas.visible = true
}
}

kglad
Community Expert
Community Expert
August 4, 2011

you should use arrays; one array for each filter.  list all objects, for the corresponding filter, that should be visible.  eg,

var educationA:Array = [btnColorado,btnTexas...];

var healthA:Array = [btnTexas,...

var etc

do that for each filter.  you'll then be set-up to display objects that are in more than one array (ie, should be displayed with more than one filter):

var displayA:Array = displayF([educationA,healthA,..]);  // pass all the arrays that you want to use to simultaneously.

// don't change below

function displayF(a:Array):Array{

var returnA:Array=[];

for(var i:int=0;i<a[0].length;i++){

var inAllBool:Boolean=true;

for(var j:int=1;j<a.length;j++){

if(a.indexOf(a[0])==-1){

inAllBool=false;

break;

}

}

if(inAllBool){

returnA.push(a[0]);

}

}

return returnA;

}