private function removeSelected(queryResults:Array):void { for each (var iGr:Graphic in queryResults) { for each (var gr:Graphic in resultsGraphicsLayer.graphicProvider) { if (iGr.geometry.toString() == gr.geometry.toString()) { resultsGraphicsLayer.remove(gr); } } } cursorManager.removeBusyCursor(); }
Solved! Go to Solution.
private function removeSelected(queryResults:Array):void { for each (var iGr:Graphic in queryResults) { for each (var gr:Graphic in resultsGraphicsLayer.graphicProvider) { if (ObjectUtil.compare(iGr.attributes, gr.attributes) == 0) { resultsGraphicsLayer.remove(gr); break; } } } cursorManager.removeBusyCursor(); }private function removeSelected(queryResults:Array):void { for each (var iGr:Graphic in queryResults) { for each (var gr:Graphic in resultsGraphicsLayer.graphicProvider) { if (ObjectUtil.compare(iGr.attributes, gr.attributes) == 0) { resultsGraphicsLayer.remove(gr); break; } } } cursorManager.removeBusyCursor(); }Try this:private function removeSelected(queryResults:Array):void { for each (var iGr:Graphic in queryResults) { for each (var gr:Graphic in resultsGraphicsLayer.graphicProvider) { if (ObjectUtil.compare(iGr.attributes, gr.attributes) == 0) { resultsGraphicsLayer.remove(gr); break; } } } cursorManager.removeBusyCursor(); }
I've added a break; and am using ObjectUtil.compare() on the attributes assuming the attributes are being requested and are different enough from layer to layer. You could compare the geometries instead but it may be a little slower.
If you knew which features in the graphics layer were from which layers, you could just compare their object id fields.
See:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/utils/ObjectUtil.html