<?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: Is it possible to access data from a clicked graphic? in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462807#M10636</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply Ken. I tried the method you suggested (using MouseEvent.CLICK instead), but I'm getting a similar error to before.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my function that gets called on mouse click:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp; protected function onGraphicMouseClick(event:MouseEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var clickedGraphic:Graphic = Graphic(event.target);
&amp;nbsp;&amp;nbsp;&amp;nbsp; trace("event.target = " + event.target.toString());
&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And i'm getting the following error on the first line of that function:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;TypeError: Error #1034: Type Coercion failed: cannot convert CompositeSymbolComponent@16e429e1 to com.esri.ags.Graphic.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So it looks like my event.target is still pointing to the CompositeSymbol instead of the Graphic.&amp;nbsp; Are you using a symbol of some sort in the application that your example code came from?&amp;nbsp; If so, how did you get around this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 20:33:37 GMT</pubDate>
    <dc:creator>JasonCantrell</dc:creator>
    <dc:date>2021-12-11T20:33:37Z</dc:date>
    <item>
      <title>Is it possible to access data from a clicked graphic?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462805#M10634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've got a map application with dynamically generated map points in several layers (each layer displays a different colored map point). I'm trying to select a map point by clicking on it and then triggering some other functionality using some string data that is unique to the clicked map point. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So far I've added a click handler to my graphics layer, and I'm displaying the contents of event.target as a String in a trace statement when I click on a graphic in that layer.&amp;nbsp; When I do that, the end of the long target string is "mapLayer.Graphic4760.CompositeSymbolComponent4777".&amp;nbsp; I've been able to trigger events based on having a specific map layer clicked before (with one clickHandler function for several different layers) so I know I can grab that from event.target, and it appears I should be able to access the Graphic and/or the CompositeSymbol as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my click handler, I tried: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var clickedGraphic:Graphic = new Graphic(); clickedGraphic = event.target as Graphic; trace("click: " + clickedGraphic.attributes.toString());&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but this gives me the following error: "Cannot access a property or method of a null object reference.", which tells me that the graphic is not actually getting passed through event.target, or I'm not referencing it properly in the code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is it possible for me to grab some string data (like the attributes or the toolTip) from the graphic that I clicked on (through event.target)?&amp;nbsp; I'm using a CompositeSymbol in my graphics layer, which is composed of a SimpleMarkerSymbol and a TextSymbol.&amp;nbsp; Would it be possible for me to grab data from the TextSymbol through event.target instead?&amp;nbsp; It seems like one of these should be possible, but I just don't know how to properly reference and access that data in my GraphicsLayer clickHandler.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2014 12:48:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462805#M10634</guid>
      <dc:creator>JasonCantrell</dc:creator>
      <dc:date>2014-03-25T12:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to access data from a clicked graphic?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462806#M10635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What I did is add an event listener to each graphic that I added to my map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;for each (var graphic:Graphic in featureSet.features) { &amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.toolTip = "Site ID: " + graphic.attributes["Site_ID"]; &amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.addEventListener(MouseEvent.ROLL_OVER, onMouseOver);&amp;nbsp; //you could also add MouseEvent.CLICK &amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.id = "Dive"; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am able to get the graphic's information in the onMouseOver event&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;private function onMouseOver(event:MouseEvent):void { &amp;nbsp;&amp;nbsp;&amp;nbsp; var graphic:Graphic = Graphic(event.target); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; var objectid = graphic.attributes["OBJECTID"] //etc &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2014 13:35:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462806#M10635</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2014-03-25T13:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to access data from a clicked graphic?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462807#M10636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply Ken. I tried the method you suggested (using MouseEvent.CLICK instead), but I'm getting a similar error to before.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my function that gets called on mouse click:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp; protected function onGraphicMouseClick(event:MouseEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var clickedGraphic:Graphic = Graphic(event.target);
&amp;nbsp;&amp;nbsp;&amp;nbsp; trace("event.target = " + event.target.toString());
&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And i'm getting the following error on the first line of that function:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;TypeError: Error #1034: Type Coercion failed: cannot convert CompositeSymbolComponent@16e429e1 to com.esri.ags.Graphic.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So it looks like my event.target is still pointing to the CompositeSymbol instead of the Graphic.&amp;nbsp; Are you using a symbol of some sort in the application that your example code came from?&amp;nbsp; If so, how did you get around this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:33:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462807#M10636</guid>
      <dc:creator>JasonCantrell</dc:creator>
      <dc:date>2021-12-11T20:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to access data from a clicked graphic?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462808#M10637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is what my event target and graphic variables look like in the onMouseOver function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using a UniqueValueRenderer with simple marker symbols, not composite symbols, to symbolize the graphics.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]32524[/ATTACH][ATTACH=CONFIG]32525[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2014 13:56:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462808#M10637</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2014-03-26T13:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to access data from a clicked graphic?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462809#M10638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using event.currentTarget seemed to solve my problem, and I successfully assigned the clicked graphic to my new graphic variable.&amp;nbsp; Thanks for the help, Ken!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2014 14:03:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462809#M10638</guid>
      <dc:creator>JasonCantrell</dc:creator>
      <dc:date>2014-03-26T14:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to access data from a clicked graphic?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462810#M10639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Ken for the answer. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I was trying to do this for one of my project and saw this post and it's coming to be pretty handy. I am able to read values from my XY&amp;nbsp; mappoint graphic pn mouseClick event. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The challenge I have is that my project is a IPAD app and I don't think tooltip are recommended. I am thinking maybe I need to use some kind of popup. Any advice or suggestions?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2014 16:55:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462810#M10639</guid>
      <dc:creator>KomanDiabate</dc:creator>
      <dc:date>2014-03-26T16:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to access data from a clicked graphic?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462811#M10640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Never mind guys. I figured it out. Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Mar 2014 21:30:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/is-it-possible-to-access-data-from-a-clicked/m-p/462811#M10640</guid>
      <dc:creator>KomanDiabate</dc:creator>
      <dc:date>2014-03-26T21:30:08Z</dc:date>
    </item>
  </channel>
</rss>

