<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Loading all features within a featureLayer into an array in ArcGIS Viewer for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273790#M8257</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried another way that made a bit more sense to me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have successfully loaded an array with the unselected features and am trying to pass their geometries into a query and then pass the query into selectFeatures() &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For some reason the query is not working out. The alert before query1 shows the right number of unselected points but the alert after the query shows 0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; protected function InvertSelBtn_clickHandler(event:MouseEvent):void{
&amp;nbsp;&amp;nbsp;&amp;nbsp; var i:Number = new Number;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var marker:Boolean = false;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //holds all features in the targetLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; var features:Array = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //holds all currently selected features in targetLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; var selected:Array = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //holds all features that are not currently selected&amp;nbsp; - to be selected
&amp;nbsp;&amp;nbsp;&amp;nbsp; var notSelected:Array = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //add features that are currently selected to array selected, then clear selection
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;targetLayer.selectedFeatures.length;i++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var selFeature:Graphic = targetLayer.selectedFeatures&lt;I&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selected.push(selFeature);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; //last query selects all points
&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.clearSelection();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //this selects all features
&amp;nbsp;&amp;nbsp;&amp;nbsp; var query:Query = new Query;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.where = "1=1";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //this.cursorManager.setBusyCursor(); 
&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.selectFeatures(query,"new",new AsyncResponder(onResult, onFault));
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //if select all fails
&amp;nbsp;&amp;nbsp;&amp;nbsp; function onFault(info:Array, token:FeatureLayer = null):void{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show("Error During Invert Selection.");
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //if selection is successful
&amp;nbsp;&amp;nbsp;&amp;nbsp; function onResult(info:Array, token:FeatureLayer = null):void{
&amp;nbsp;&amp;nbsp;&amp;nbsp; //upon result of selecting all features, add all features from targetLayer to array features, then clear selection
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;targetLayer.selectedFeatures.length;i++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var feature:Graphic = targetLayer.selectedFeatures&lt;I&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; features.push(feature);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //targetLayer.clearSelection();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //nested for loop to iterate through features (run once for each feature in targetLayer)
&amp;nbsp;&amp;nbsp;&amp;nbsp; //then iterate through selected (run once for each feature in selFeatures)
&amp;nbsp;&amp;nbsp;&amp;nbsp; //if their objects match, marker set to true - if at the end of the inside loop marker is still false
&amp;nbsp;&amp;nbsp;&amp;nbsp; //no match was found and 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(x=0;x&amp;lt;features.length;x++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(y=0;y&amp;lt;selected.length;y++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //if there is ever a match, mark boolean as true, and features&lt;X&gt; wont be added to notSelected
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //i will have to change this to work with line, poly -for now points is fine
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(features&lt;X&gt;.geometry as MapPoint === selected&lt;Y&gt;.geometry as MapPoint){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; marker=true;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //if match wasnt found in inside for loop, then the feature wasnt selected and will be added to notSelected
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(marker===false){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; notSelected.push(features&lt;X&gt;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //speed things up and break the loop if all non selected features have been added
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(features.length&amp;lt;=(selected.length+notSelected.length)){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; //this alert broke the selection screen for some reason lol
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Alert.show("# features selected: " +selected.length.toString()+"+ # features not selected: "+notSelected.length.toString()+"= # features total: "+features.length.toString());
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //loop through notSelected, adding each feature in it to selection of targetLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.clearSelection(); 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show(notSelected.length.toString());
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var query1:Query = new Query;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query1.geometry = notSelected.geometry;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query1.spatialRelationship=Query.SPATIAL_REL_OVERLAPS;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.selectFeatures(query1,"new",null);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show(targetLayer.selectedFeatures.length.toString());
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }&lt;/X&gt;&lt;/Y&gt;&lt;/X&gt;&lt;/X&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 13:22:15 GMT</pubDate>
    <dc:creator>MattGiles</dc:creator>
    <dc:date>2021-12-11T13:22:15Z</dc:date>
    <item>
      <title>Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273785#M8252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a way to load all the features from a FeatureLayer into an Array (similar to FeatureLayer.selectedFeatures but for ALL the features) so they can be compared with an array of graphics? Or do I have to select all features in the FeatureLayer first and then use .selectedFeatures???&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2012 15:35:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273785#M8252</guid>
      <dc:creator>MattGiles</dc:creator>
      <dc:date>2012-02-15T15:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273786#M8253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;See:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/FeatureLayer.html#graphicProvider"&gt;http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/FeatureLayer.html#graphicProvider&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2012 16:58:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273786#M8253</guid>
      <dc:creator>DasaPaddock</dc:creator>
      <dc:date>2012-02-15T16:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273787#M8254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have looked at that already and doesnt seem to be working for me: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
protected function InvertSelBtn_clickHandler(event:MouseEvent):void{
&amp;nbsp;&amp;nbsp;&amp;nbsp; var i:Number = new Number;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //array to hold selected features (graphics) in target layer
&amp;nbsp;&amp;nbsp;&amp;nbsp; var selected:Array = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;targetLayer.selectedFeatures.length;i++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var graphic:Graphic = targetLayer.selectedFeatures&lt;I&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selected.push(graphic);
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //clear selected features in targetLayer after selected in loaded with the features that were selected
&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.clearSelection();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show("before loading all features");
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //this holds all features in the targetLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; var targetLayerFeatures:ArrayCollection = new ArrayCollection;
&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayerFeatures = targetLayer.graphicProvider as ArrayCollection;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show(targetLayerFeatures.contains(selected[1]).toString());
&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I load all selected features into an array of graphics - this works as i can print the geometry of the features and they are correct. Then i load all the features in the targetLayer into an arraycollection using the graphics provider. But arraycollection.length is 0 (so its not loading correctly) and the alert at the bottom prints false (again indicating the arraycollection is not loading correctly - since selected[1] comes from the targetLayer as well).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What am I doing incorrectly?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am doing this to add invert selection functionality to my selection widget. Once i have an array of all the features in the targetLayer I will use a query to invert the selection. Is there an easier way of doing this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:22:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273787#M8254</guid>
      <dc:creator>MattGiles</dc:creator>
      <dc:date>2021-12-11T13:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273788#M8255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The graphicsProvider is just the features already loaded into the FeatureLayer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To do what you want, I'd try calling this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/FeatureLayer.html#queryIds()"&gt;http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/FeatureLayer.html#queryIds()&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;with Query.where = "1=1".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then invert the selection by calling selectFeatures() with Query.objectIds.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2012 22:16:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273788#M8255</guid>
      <dc:creator>DasaPaddock</dc:creator>
      <dc:date>2012-02-15T22:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273789#M8256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry Im new to flex - could you explain what queryID does exactly (nothing was selected when i used targetLayer.queryIds with query.where="1=1". &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also could you explain how i would use query.objectIds??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 02:35:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273789#M8256</guid>
      <dc:creator>MattGiles</dc:creator>
      <dc:date>2012-02-16T02:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273790#M8257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried another way that made a bit more sense to me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have successfully loaded an array with the unselected features and am trying to pass their geometries into a query and then pass the query into selectFeatures() &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For some reason the query is not working out. The alert before query1 shows the right number of unselected points but the alert after the query shows 0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; protected function InvertSelBtn_clickHandler(event:MouseEvent):void{
&amp;nbsp;&amp;nbsp;&amp;nbsp; var i:Number = new Number;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var marker:Boolean = false;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //holds all features in the targetLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; var features:Array = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //holds all currently selected features in targetLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; var selected:Array = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //holds all features that are not currently selected&amp;nbsp; - to be selected
&amp;nbsp;&amp;nbsp;&amp;nbsp; var notSelected:Array = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //add features that are currently selected to array selected, then clear selection
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;targetLayer.selectedFeatures.length;i++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var selFeature:Graphic = targetLayer.selectedFeatures&lt;I&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selected.push(selFeature);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; //last query selects all points
&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.clearSelection();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //this selects all features
&amp;nbsp;&amp;nbsp;&amp;nbsp; var query:Query = new Query;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.where = "1=1";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //this.cursorManager.setBusyCursor(); 
&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.selectFeatures(query,"new",new AsyncResponder(onResult, onFault));
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //if select all fails
&amp;nbsp;&amp;nbsp;&amp;nbsp; function onFault(info:Array, token:FeatureLayer = null):void{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show("Error During Invert Selection.");
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //if selection is successful
&amp;nbsp;&amp;nbsp;&amp;nbsp; function onResult(info:Array, token:FeatureLayer = null):void{
&amp;nbsp;&amp;nbsp;&amp;nbsp; //upon result of selecting all features, add all features from targetLayer to array features, then clear selection
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;targetLayer.selectedFeatures.length;i++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var feature:Graphic = targetLayer.selectedFeatures&lt;I&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; features.push(feature);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //targetLayer.clearSelection();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //nested for loop to iterate through features (run once for each feature in targetLayer)
&amp;nbsp;&amp;nbsp;&amp;nbsp; //then iterate through selected (run once for each feature in selFeatures)
&amp;nbsp;&amp;nbsp;&amp;nbsp; //if their objects match, marker set to true - if at the end of the inside loop marker is still false
&amp;nbsp;&amp;nbsp;&amp;nbsp; //no match was found and 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(x=0;x&amp;lt;features.length;x++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(y=0;y&amp;lt;selected.length;y++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //if there is ever a match, mark boolean as true, and features&lt;X&gt; wont be added to notSelected
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //i will have to change this to work with line, poly -for now points is fine
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(features&lt;X&gt;.geometry as MapPoint === selected&lt;Y&gt;.geometry as MapPoint){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; marker=true;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //if match wasnt found in inside for loop, then the feature wasnt selected and will be added to notSelected
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(marker===false){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; notSelected.push(features&lt;X&gt;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //speed things up and break the loop if all non selected features have been added
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(features.length&amp;lt;=(selected.length+notSelected.length)){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; //this alert broke the selection screen for some reason lol
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Alert.show("# features selected: " +selected.length.toString()+"+ # features not selected: "+notSelected.length.toString()+"= # features total: "+features.length.toString());
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //loop through notSelected, adding each feature in it to selection of targetLayer
&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.clearSelection(); 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show(notSelected.length.toString());
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; var query1:Query = new Query;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query1.geometry = notSelected.geometry;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query1.spatialRelationship=Query.SPATIAL_REL_OVERLAPS;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.selectFeatures(query1,"new",null);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show(targetLayer.selectedFeatures.length.toString());
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }&lt;/X&gt;&lt;/Y&gt;&lt;/X&gt;&lt;/X&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:22:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273790#M8257</guid>
      <dc:creator>MattGiles</dc:creator>
      <dc:date>2021-12-11T13:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273791#M8258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I solved the query issue - but the real issue is the line that compares geometries from features&lt;X&gt; to geometries from selected&lt;Y&gt;...this if statement is never entered...can someone shed some light?&lt;/Y&gt;&lt;/X&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 13:53:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273791#M8258</guid>
      <dc:creator>MattGiles</dc:creator>
      <dc:date>2012-02-16T13:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273792#M8259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;M Giles,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Why not just compare their ObjectIds or their attributes?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 13:58:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273792#M8259</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2012-02-16T13:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273793#M8260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is their a big difference between comparing the graphics attributes and comparing the graphics geometries? I tried both and neither worked..I have it working now by comparing their geometries type casted into strings (ex: features&lt;X&gt;.geometry.toString()) - this seems like a bad way of doing it but it seems to work...&lt;/X&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Invert now works with points but it seems to crap out with polygons (sometimes). I have a layer with ~100 polygons and when i select ~25-50 of them and invert selection i get the error message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; RPC Fault faultString="Unable to complete&amp;nbsp; operation." faultCode="400" faultDetail="Unable to complete Query operation."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but when i select ~90 of them it works..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas on what could be causing this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 16:16:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273793#M8260</guid>
      <dc:creator>MattGiles</dc:creator>
      <dc:date>2012-02-16T16:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273794#M8261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;M Giles,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Using the ObjectIDs would be much cleaner and is the was it is done in ArcMap. The issue you are likely having is just the size of the data being requested if it was some 100 simple four point polygons then that would be a JSON string of 400 X and Ys on top of all the other data that is in the JSON response. The whole problem with the selection widget and what you are attempting to do is you are treating a web mapping app like it is an online ArcMap which it will never be.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 16:22:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273794#M8261</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2012-02-16T16:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273795#M8262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK sounds good - I get that I am pushing the limits of the app but an invert selection option is required for the nature of the application (will be used to highlight deficiencies in monitoring programs etc) since query's spatial relationship does not include things like "does not contain"...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I assume using the objectIDs to compare would reduce the size of the JSON string? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Instead of the line " if(features[x1].geometry.toString() == selected[y1].geometry.toString())" I tried to use (features[x1].attributes == selected[y1].attributes) and (features[x1].id == selected[y1].id) and neither worked...I attached my code below - is there any reason you can see why neither of these are working? Thanks so much Robert for your help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;protected function InvertSelBtn_clickHandler(event:MouseEvent):void{
&amp;nbsp;&amp;nbsp;&amp;nbsp; //reset all three arrays
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; features = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; selected = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; notSelected = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.cursorManager.setBusyCursor();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //add features that are currently selected to array selected, then clear selection
&amp;nbsp;&amp;nbsp;&amp;nbsp; var i:Number = new Number;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;targetLayer.selectedFeatures.length;i++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var selFeature:Graphic = targetLayer.selectedFeatures&lt;I&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selected.push(selFeature);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.clearSelection();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //this selects all features
&amp;nbsp;&amp;nbsp;&amp;nbsp; var query:Query = new Query;
&amp;nbsp;&amp;nbsp;&amp;nbsp; query.where = "1=1";
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //this.cursorManager.setBusyCursor(); 
&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.selectFeatures(query,"new",new AsyncResponder(onInvertSelectAllResult, onInvertSelectAllFault));
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //if select all during invert fails
&amp;nbsp;&amp;nbsp;&amp;nbsp; private function onInvertSelectAllFault(info:Array, token:FeatureLayer = null):void{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show("Error During Invert Selection.");
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //if select all during invert is successful - continue with invert process
&amp;nbsp;&amp;nbsp;&amp;nbsp; private function onInvertSelectAllResult(info:Array, token:FeatureLayer = null):void{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var marker:Boolean = false;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //upon result of selecting all features, add all features from targetLayer to array features, then clear selection
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var i:Number = new Number;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;targetLayer.selectedFeatures.length;i++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var feature:Graphic = targetLayer.selectedFeatures&lt;I&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; features.push(feature);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.clearSelection(); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //nested for loop to iterate through features (run once for each feature in targetLayer)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //then iterate through selected (run once for each feature in selFeatures)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //if their objects match, marker set to true - if at the end of the inside loop marker is still false
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //no match was found and the feature&lt;X&gt; is loaded into notSelected
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var x1:Number = new Number;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var y1:Number = new Number;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(x1=0;x1&amp;lt;features.length;x1++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; marker=false;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(y1=0;y1&amp;lt;selected.length;y1++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //if there is ever a match, mark boolean as true, and features&lt;X&gt; wont be added to notSelected
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //i will have to change this to work with line, poly -for now points is fine
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(features[x1].geometry.toString() == selected[y1].geometry.toString()){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //this lets us know that there was a match and nothing should be added to notSelected
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; marker=true;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //if match wasnt found in inside for loop, then the feature wasnt selected and will be added to notSelected
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(marker===false){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; notSelected.push(features[x1]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //pass the array of unselected features into featSet, then pass to unionGeom to get a geometry back
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var featSet:FeatureSet = new FeatureSet(notSelected);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var unionGeom:Geometry = SelectionWidgetUtil.unionGeoms(featSet);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //now run query with unionGeom
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var query1:Query = new Query;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query1.geometry=unionGeom;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.selectFeatures(query1,"new",new AsyncResponder(onInvertResult, onInvertFault, targetLayer));&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; } 

&amp;nbsp; 
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; //on invert selection result
&amp;nbsp;&amp;nbsp; private function onInvertResult(info:Array, token:FeatureLayer = null):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.cursorManager.removeBusyCursor();
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; //this makes the selection results page be displayed upon selection
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* var e:Event = new SelectionFeatureLayerEvent(SelectionFeatureLayerEvent.SHOW_RESULTS, null);
&amp;nbsp;&amp;nbsp;&amp;nbsp; dispatchEvent(e); */
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; //on invert selection fault
&amp;nbsp;&amp;nbsp; private function onInvertFault(info:Object, token:Object = null):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.cursorManager.removeBusyCursor();
&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show("Could not complete Selection. Please try again.\n" + info.toString(), 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Selection Error", Alert.OK);
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; &lt;/X&gt;&lt;/X&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:22:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273795#M8262</guid>
      <dc:creator>MattGiles</dc:creator>
      <dc:date>2021-12-11T13:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273796#M8263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;M Giles,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; Honestly I can not begin to understand the logic in your code. So let me try to tell you how I would approach it, (What you are missing from what Dasa was directing you towards).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;OL&gt;&lt;BR /&gt;&lt;LI&gt;You have a featurelayer and it has certain features selected&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;You want to invert that selection meaning select all the unselected features.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;You would begin by building an array of ObjectIds from the current selection.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;You would then use targetLayer selectFeatures and the query that you would pass is:&lt;/LI&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var query:Query = new Query;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query.where = "NOT " targetLayer.layerDetails.objectIdField + " IN (" + OIDArr.join(",") + ")";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; targetLayer.selectFeatures(query,"new",new AsyncResponder(onInvertSelectAllResult, onInvertSelectAllFault));&lt;/PRE&gt; Where OIDArr is the array containing the objectids of the current selection.&lt;BR /&gt;&lt;/OL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:22:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273796#M8263</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-11T13:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273797#M8264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes im very inexperienced with flex and dont know / understand the full capabilities that are available to me - for this reason alot of my code is very illogical. Thanks Robert Ill try that method of doing it. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One more question for you - how do I load an array from the targetLayer.queryIds() function as it returns an asynctoken...i tried OIDArr = targetLayer.queryIds() as Array but that was unsuccessful&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;..Ive been searching all over the net and cant find an example that uses .queryIds() function.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 18:13:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273797#M8264</guid>
      <dc:creator>MattGiles</dc:creator>
      <dc:date>2012-02-16T18:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273798#M8265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;M Giles,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; For a sample close to using QueryIds look here: It actually use QueryTask executeForIds but will give you what you need.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/webapi/flex/samples/01nq/01nq00000060000000.htm"&gt;http://help.arcgis.com/en/webapi/flex/samples/01nq/01nq00000060000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also I don't think you even have to go that route... Just loop though your selected features and add the value of the ObjectID field to an array.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 18:39:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273798#M8265</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2012-02-16T18:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273799#M8266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;But how do I access the objectIDs from targetLayer.selectedFeatures? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var OIDArr:Array = new Array;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(anX=0;anX&amp;lt;targetLayer.selectedFeatures.length;anX++){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show(targetLayer.selectedFeatures[anX].id)
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but that simply returns the graphic IDs which are not the same..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried queryTask executeForIds() which works but it returns all the ids in targetLayer. How would I a.make a new FeatureLayer from just the selected features in targetLayer or b.tell it to only return Ids for those features that are selected??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This seems so simple yet so difficult for a noob like myself. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:22:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273799#M8266</guid>
      <dc:creator>MattGiles</dc:creator>
      <dc:date>2021-12-11T13:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273800#M8267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;M Giles,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; The ObjectID is a field in the attributes of the feature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var OIDArr:Array = new Array;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(anX=0;anX&amp;lt;targetLayer.selectedFeatures.length;anX++){ &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show(targetLayer.selectedFeatures[anX].attributes[targetLayer.layerDetails.objectIdField]) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You should probably start promoting some of these posts that you find helpful.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Feb 2012 20:56:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273800#M8267</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2012-02-16T20:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Loading all features within a featureLayer into an array</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273801#M8268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks so much for your help Robert. Much appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 12:24:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/loading-all-features-within-a-featurelayer-into-an/m-p/273801#M8268</guid>
      <dc:creator>MattGiles</dc:creator>
      <dc:date>2012-02-17T12:24:12Z</dc:date>
    </item>
  </channel>
</rss>

