<?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: How to bind object instances created in Actiom script to properties in mxml? in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-bind-object-instances-created-in-actiom/m-p/661409#M14821</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can still instantiate the Bindable query task outside of the function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You just set its paramaters when the button is clicked (or when you need to execute the querytask.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code is an adaptation of the ESRI sample at: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/en/webapi/flex/samples/index.html#/Query_result_in_table/01nq0000005t000000/" rel="nofollow" target="_blank"&gt;http://help.arcgis.com/en/webapi/flex/samples/index.html#/Query_result_in_table/01nq0000005t000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have just commented out the MXML query and query task, and created and used them in actionscript. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt; &amp;lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:mx="library://ns.adobe.com/flex/mx" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:esri="http://www.esri.com/2008/ags" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:s="library://ns.adobe.com/flex/spark" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pageTitle="Query Task (without a map)"&amp;gt;&amp;nbsp; &amp;lt;!--&amp;nbsp; This sample shows how to query the server and displaying&amp;nbsp; the result in a datagrid.&amp;nbsp; The query is sent using the execute() method on a QueryTask.&amp;nbsp;&amp;nbsp;&amp;nbsp; This sample sets up a QueryTask (what layer on what server to query).&amp;nbsp; When the user clicks the "Get Details" button, a Query is sent with&amp;nbsp; the user-provided text to search for.&amp;nbsp; Meanwhile a DataGrid has been created which listens for the results&amp;nbsp; (using executeLastResult) from the querytask.&amp;nbsp; --&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;s:layout&amp;gt; &amp;nbsp; &amp;lt;s:VerticalLayout horizontalAlign="center" paddingTop="25"/&amp;gt;&amp;nbsp; &amp;lt;/s:layout&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fx:Script&amp;gt; &amp;nbsp; &amp;lt;![CDATA[ &amp;nbsp;&amp;nbsp; import com.esri.ags.tasks.QueryTask; &amp;nbsp;&amp;nbsp; import com.esri.ags.tasks.supportClasses.Query; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; [Bindable] &amp;nbsp;&amp;nbsp; public var queryTask:QueryTask; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; protected function button1_clickHandler(event:MouseEvent):void &amp;nbsp;&amp;nbsp; { &amp;nbsp;&amp;nbsp;&amp;nbsp; // Set up the query &amp;nbsp;&amp;nbsp;&amp;nbsp; var query:Query = new Query; &amp;nbsp;&amp;nbsp;&amp;nbsp; query.outFields = ["STATE_NAME","STATE_FIPS","SUB_REGION","STATE_ABBR","POP2000","POP2007"] &amp;nbsp;&amp;nbsp;&amp;nbsp; query.returnGeometry = false; &amp;nbsp;&amp;nbsp;&amp;nbsp; query.text = stateName.text; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //Use the bindable querytask &amp;nbsp;&amp;nbsp;&amp;nbsp; queryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5") &amp;nbsp;&amp;nbsp;&amp;nbsp; queryTask.useAMF = false; &amp;nbsp;&amp;nbsp;&amp;nbsp; queryTask.execute(query); &amp;nbsp;&amp;nbsp; } &amp;nbsp; ]]&amp;gt;&amp;nbsp; &amp;lt;/fx:Script&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fx:Declarations&amp;gt; &amp;nbsp; &amp;lt;!--&amp;lt;esri:QueryTask id="queryTask" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; useAMF="false"/&amp;gt; &amp;nbsp; &amp;lt;esri:Query id="query" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFields="[STATE_NAME,STATE_FIPS,SUB_REGION,STATE_ABBR,POP2000,POP2007]" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnGeometry="false" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text="{stateName.text}"/&amp;gt;--&amp;gt;&amp;nbsp; &amp;lt;/fx:Declarations&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;s:Panel title="Using Query tasks without maps"&amp;gt; &amp;nbsp; &amp;lt;s:layout&amp;gt; &amp;nbsp;&amp;nbsp; &amp;lt;s:VerticalLayout/&amp;gt; &amp;nbsp; &amp;lt;/s:layout&amp;gt; &amp;nbsp; &amp;lt;s:HGroup verticalAlign="middle"&amp;gt; &amp;nbsp;&amp;nbsp; &amp;lt;s:Label text="US state name: "/&amp;gt; &amp;nbsp;&amp;nbsp; &amp;lt;s:TextInput id="stateName" text="Carolina"/&amp;gt; &amp;nbsp;&amp;nbsp; &amp;lt;s:Button click="button1_clickHandler(event)" label="Get Details"/&amp;gt; &amp;nbsp; &amp;lt;/s:HGroup&amp;gt; &amp;nbsp; &amp;lt;mx:DataGrid id="resultsGrid" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataProvider="{queryTask.executeLastResult.attributes}" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; visible="{queryTask.executeLastResult != null}"&amp;gt; &amp;nbsp;&amp;nbsp; &amp;lt;mx:columns&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:DataGridColumn dataField="STATE_NAME" headerText="State Name"/&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:DataGridColumn dataField="SUB_REGION" headerText="Region"/&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:DataGridColumn dataField="STATE_FIPS" headerText="FIPS"/&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:DataGridColumn dataField="STATE_ABBR" headerText="Abbreviation"/&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:DataGridColumn dataField="POP2000" headerText="Population 2000"/&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:DataGridColumn dataField="POP2007" headerText="Population 2007"/&amp;gt; &amp;nbsp;&amp;nbsp; &amp;lt;/mx:columns&amp;gt; &amp;nbsp; &amp;lt;/mx:DataGrid&amp;gt;&amp;nbsp; &amp;lt;/s:Panel&amp;gt; &amp;lt;/s:Application&amp;gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Jul 2012 00:07:56 GMT</pubDate>
    <dc:creator>MarkHoyland</dc:creator>
    <dc:date>2012-07-13T00:07:56Z</dc:date>
    <item>
      <title>How to bind object instances created in Actiom script to properties in mxml?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-bind-object-instances-created-in-actiom/m-p/661408#M14820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How can we reference an object instance created with ActionScript in mxml?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So let's say I create a function that creates a query task and a query. I want the results of this Query to populate a datagrid that has been created in mxml. If I set the dataProvider of the datagrid to&amp;nbsp;&amp;nbsp; dataProvider="{querytaskindustry.executeLastResult.attributes}" &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in mxml I get a warning saying that the binding will not occur because it can't identify querytask. I believe this happens because I did not set the variable for the querytask to be bindable. However I can't set a variable to be bindable inside a function. If I create the querytask outside the function and set it as bindable it does not work because the function is based on a button click so the query is just created when the user clicks the search button, so I need to create the querytask and query inside the function. What would be the solution for the mxml datagrid dataProvider property identify the querytask? Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jul 2012 18:28:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-bind-object-instances-created-in-actiom/m-p/661408#M14820</guid>
      <dc:creator>ionarawilson1</dc:creator>
      <dc:date>2012-07-12T18:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to bind object instances created in Actiom script to properties in mxml?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-bind-object-instances-created-in-actiom/m-p/661409#M14821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can still instantiate the Bindable query task outside of the function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You just set its paramaters when the button is clicked (or when you need to execute the querytask.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code is an adaptation of the ESRI sample at: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://help.arcgis.com/en/webapi/flex/samples/index.html#/Query_result_in_table/01nq0000005t000000/" rel="nofollow" target="_blank"&gt;http://help.arcgis.com/en/webapi/flex/samples/index.html#/Query_result_in_table/01nq0000005t000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have just commented out the MXML query and query task, and created and used them in actionscript. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt; &amp;lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:mx="library://ns.adobe.com/flex/mx" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:esri="http://www.esri.com/2008/ags" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:s="library://ns.adobe.com/flex/spark" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pageTitle="Query Task (without a map)"&amp;gt;&amp;nbsp; &amp;lt;!--&amp;nbsp; This sample shows how to query the server and displaying&amp;nbsp; the result in a datagrid.&amp;nbsp; The query is sent using the execute() method on a QueryTask.&amp;nbsp;&amp;nbsp;&amp;nbsp; This sample sets up a QueryTask (what layer on what server to query).&amp;nbsp; When the user clicks the "Get Details" button, a Query is sent with&amp;nbsp; the user-provided text to search for.&amp;nbsp; Meanwhile a DataGrid has been created which listens for the results&amp;nbsp; (using executeLastResult) from the querytask.&amp;nbsp; --&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;s:layout&amp;gt; &amp;nbsp; &amp;lt;s:VerticalLayout horizontalAlign="center" paddingTop="25"/&amp;gt;&amp;nbsp; &amp;lt;/s:layout&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fx:Script&amp;gt; &amp;nbsp; &amp;lt;![CDATA[ &amp;nbsp;&amp;nbsp; import com.esri.ags.tasks.QueryTask; &amp;nbsp;&amp;nbsp; import com.esri.ags.tasks.supportClasses.Query; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; [Bindable] &amp;nbsp;&amp;nbsp; public var queryTask:QueryTask; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; protected function button1_clickHandler(event:MouseEvent):void &amp;nbsp;&amp;nbsp; { &amp;nbsp;&amp;nbsp;&amp;nbsp; // Set up the query &amp;nbsp;&amp;nbsp;&amp;nbsp; var query:Query = new Query; &amp;nbsp;&amp;nbsp;&amp;nbsp; query.outFields = ["STATE_NAME","STATE_FIPS","SUB_REGION","STATE_ABBR","POP2000","POP2007"] &amp;nbsp;&amp;nbsp;&amp;nbsp; query.returnGeometry = false; &amp;nbsp;&amp;nbsp;&amp;nbsp; query.text = stateName.text; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //Use the bindable querytask &amp;nbsp;&amp;nbsp;&amp;nbsp; queryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5") &amp;nbsp;&amp;nbsp;&amp;nbsp; queryTask.useAMF = false; &amp;nbsp;&amp;nbsp;&amp;nbsp; queryTask.execute(query); &amp;nbsp;&amp;nbsp; } &amp;nbsp; ]]&amp;gt;&amp;nbsp; &amp;lt;/fx:Script&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fx:Declarations&amp;gt; &amp;nbsp; &amp;lt;!--&amp;lt;esri:QueryTask id="queryTask" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; useAMF="false"/&amp;gt; &amp;nbsp; &amp;lt;esri:Query id="query" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outFields="[STATE_NAME,STATE_FIPS,SUB_REGION,STATE_ABBR,POP2000,POP2007]" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnGeometry="false" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text="{stateName.text}"/&amp;gt;--&amp;gt;&amp;nbsp; &amp;lt;/fx:Declarations&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;s:Panel title="Using Query tasks without maps"&amp;gt; &amp;nbsp; &amp;lt;s:layout&amp;gt; &amp;nbsp;&amp;nbsp; &amp;lt;s:VerticalLayout/&amp;gt; &amp;nbsp; &amp;lt;/s:layout&amp;gt; &amp;nbsp; &amp;lt;s:HGroup verticalAlign="middle"&amp;gt; &amp;nbsp;&amp;nbsp; &amp;lt;s:Label text="US state name: "/&amp;gt; &amp;nbsp;&amp;nbsp; &amp;lt;s:TextInput id="stateName" text="Carolina"/&amp;gt; &amp;nbsp;&amp;nbsp; &amp;lt;s:Button click="button1_clickHandler(event)" label="Get Details"/&amp;gt; &amp;nbsp; &amp;lt;/s:HGroup&amp;gt; &amp;nbsp; &amp;lt;mx:DataGrid id="resultsGrid" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dataProvider="{queryTask.executeLastResult.attributes}" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; visible="{queryTask.executeLastResult != null}"&amp;gt; &amp;nbsp;&amp;nbsp; &amp;lt;mx:columns&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:DataGridColumn dataField="STATE_NAME" headerText="State Name"/&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:DataGridColumn dataField="SUB_REGION" headerText="Region"/&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:DataGridColumn dataField="STATE_FIPS" headerText="FIPS"/&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:DataGridColumn dataField="STATE_ABBR" headerText="Abbreviation"/&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:DataGridColumn dataField="POP2000" headerText="Population 2000"/&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;mx:DataGridColumn dataField="POP2007" headerText="Population 2007"/&amp;gt; &amp;nbsp;&amp;nbsp; &amp;lt;/mx:columns&amp;gt; &amp;nbsp; &amp;lt;/mx:DataGrid&amp;gt;&amp;nbsp; &amp;lt;/s:Panel&amp;gt; &amp;lt;/s:Application&amp;gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jul 2012 00:07:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-bind-object-instances-created-in-actiom/m-p/661409#M14821</guid>
      <dc:creator>MarkHoyland</dc:creator>
      <dc:date>2012-07-13T00:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to bind object instances created in Actiom script to properties in mxml?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-bind-object-instances-created-in-actiom/m-p/661410#M14822</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oh, I see! I guess the function was not working because of another issue and not because I was declaring the queryTask outside the function! Thank you for sending me the example! This is very helpful!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jul 2012 13:35:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/how-to-bind-object-instances-created-in-actiom/m-p/661410#M14822</guid>
      <dc:creator>ionarawilson1</dc:creator>
      <dc:date>2012-07-13T13:35:17Z</dc:date>
    </item>
  </channel>
</rss>

