<?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: Accessing an AS3 function in a widget from JavaScript in a containing ASP page in ArcGIS Viewer for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/accessing-an-as3-function-in-a-widget-from/m-p/261497#M7943</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; As I explain in this thread:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/13863-Communication-between-widgets"&gt;http://forums.arcgis.com/threads/13863-Communication-between-widgets&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once you are in the index.mxml code you need to dispatch and event that your widget is listening for is the best way to handle it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 May 2011 11:04:33 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2011-05-06T11:04:33Z</dc:date>
    <item>
      <title>Accessing an AS3 function in a widget from JavaScript in a containing ASP page</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/accessing-an-as3-function-in-a-widget-from/m-p/261496#M7942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm attempting to access an AS3 function in what is essentially a modified Search widget in the v2.2 Flex Viewer from a JavaScript function on an ASP page that contains the embedded flex viewer.&amp;nbsp; As a debugging test, I can get at a function in the index.mxml page using ExternalInterface.addCallback() on that page, but that is because the index.swf is loaded in the page using swfobject.js and it has an attribute.id, so I can do a getElementById(attribute.id) in JavaScript to get a handle on the index.swf.&amp;nbsp; But I'm not sure how to get handle for something like a Search widget that is not loaded directly into the ASP page, but rather is invoked from a toolbar in the index.swf.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here are some details:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;JavaScript in ASP page, invoked by a button on the page:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
var flashvars = {};
var params = {};
var attributes = {};
attributes.id = "myMap";
swfobject.embedSWF(mapSwfUrl, "mapDiv", "100%", "98%", mapSwfVersion, xprsSwfInstUrl, flashvars, params, attributes);
. . .
function ClearMapFromAspClearButton() {
&amp;nbsp;&amp;nbsp; var flash = document.getElementById("myMap");
&amp;nbsp;&amp;nbsp; flash.AS3ClearMap("clear called from asp");
}
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;AS3 code in index.mxml:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
 &amp;lt;fx:Script&amp;gt;
&amp;nbsp; &amp;lt;![CDATA[
&amp;nbsp;&amp;nbsp; import mx.controls.Alert;
&amp;nbsp;&amp;nbsp; import flash.external.ExternalInterface;
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; public function initApp():void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ExternalInterface.available) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ExternalInterface.addCallback("AS3ClearMap", clear);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show("external interface is available");
&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; private function clear(msg:String = null):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (msg != null) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show(msg);
&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Alert.show("no message");
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; ]]&amp;gt;
 &amp;lt;/fx:Script&amp;gt;
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Clicking on the button in the ASP page generates a Flash Alert in the flex map viewer that says "clear called from asp".&amp;nbsp; This works because I have access to the index.swf object from my calling JavaScript/ASP page.&amp;nbsp; But how do I get hold of a widget loaded in my map viewer?&amp;nbsp; Is it necessary to create some kind of bridge from index.swf to the widgets that are invoked "within" it?&amp;nbsp; Or are widgets somehow accessible as children of the index.swf?&amp;nbsp; (I didn't see any such relationship when setting a break point and examining the contents of the flash object).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 May 2011 20:27:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/accessing-an-as3-function-in-a-widget-from/m-p/261496#M7942</guid>
      <dc:creator>ChrisBeaudette</dc:creator>
      <dc:date>2011-05-05T20:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing an AS3 function in a widget from JavaScript in a containing ASP page</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/accessing-an-as3-function-in-a-widget-from/m-p/261497#M7943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; As I explain in this thread:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/13863-Communication-between-widgets"&gt;http://forums.arcgis.com/threads/13863-Communication-between-widgets&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once you are in the index.mxml code you need to dispatch and event that your widget is listening for is the best way to handle it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 May 2011 11:04:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/accessing-an-as3-function-in-a-widget-from/m-p/261497#M7943</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2011-05-06T11:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Accessing an AS3 function in a widget from JavaScript in a containing ASP page</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/accessing-an-as3-function-in-a-widget-from/m-p/261498#M7944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Much appreciated, thanks Robert.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 May 2011 16:06:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/accessing-an-as3-function-in-a-widget-from/m-p/261498#M7944</guid>
      <dc:creator>ChrisBeaudette</dc:creator>
      <dc:date>2011-05-06T16:06:02Z</dc:date>
    </item>
  </channel>
</rss>

