Mithridatism
12-22-2008, 02:40 AM
I have a varying number of different markers on a map. They're stored in "markerArray". These markers have an ".icon" property, which corresponds with buttons in a list. When I click the button, every marker that has the same ".icon" in the map turns invisible. That works fine.
However, if I use the same function to make the invisible ones VISIBLE again, it only sets two visible. After that, I can only toggle those two. What could be the problem? I thought the else-if might be too much work for flash and even split the function up, but the result is always the same.
The "Dimmer" parts only add a half-transparent MC (mouse Enabled=false; of course) over the button, feel free to ignore that.
function Toggle(event:MouseEvent):void {
if (DimDone=="0"){
for(var j:uint = 0; j < MovieClip(this.parent).markerArray.length; j++){
if(MovieClip(this.parent).markerArray[j].icon == String(event.target.parent.icon)
&& MovieClip(this.parent).markerArray[j].visible == true){
MovieClip(this.parent).markerArray[j].visible = false;
if(event.target.parent.dimmed ==1){
}else{
var Dimmer:MCDimLegend = new MCDimLegend();
event.target.parent.addChild(Dimmer);
event.target.parent.dimmed =1;
}
}
DimDone="1"
}
}else{
for(var j2:uint = 0; j2 < MovieClip(this.parent).markerArray.length; j2++){
if(MovieClip(this.parent).markerArray[j2].icon == String(event.target.parent.icon)
&& MovieClip(this.parent).markerArray[j2].visible == false){
MovieClip(this.parent).markerArray[j2].visible = true;
event.target.parent.removeChildAt(3);
event.target.parent.dimmed =0;
}
DimDone="0"
}
}
}
However, if I use the same function to make the invisible ones VISIBLE again, it only sets two visible. After that, I can only toggle those two. What could be the problem? I thought the else-if might be too much work for flash and even split the function up, but the result is always the same.
The "Dimmer" parts only add a half-transparent MC (mouse Enabled=false; of course) over the button, feel free to ignore that.
function Toggle(event:MouseEvent):void {
if (DimDone=="0"){
for(var j:uint = 0; j < MovieClip(this.parent).markerArray.length; j++){
if(MovieClip(this.parent).markerArray[j].icon == String(event.target.parent.icon)
&& MovieClip(this.parent).markerArray[j].visible == true){
MovieClip(this.parent).markerArray[j].visible = false;
if(event.target.parent.dimmed ==1){
}else{
var Dimmer:MCDimLegend = new MCDimLegend();
event.target.parent.addChild(Dimmer);
event.target.parent.dimmed =1;
}
}
DimDone="1"
}
}else{
for(var j2:uint = 0; j2 < MovieClip(this.parent).markerArray.length; j2++){
if(MovieClip(this.parent).markerArray[j2].icon == String(event.target.parent.icon)
&& MovieClip(this.parent).markerArray[j2].visible == false){
MovieClip(this.parent).markerArray[j2].visible = true;
event.target.parent.removeChildAt(3);
event.target.parent.dimmed =0;
}
DimDone="0"
}
}
}