<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html" />
  <link rel="self" type="application/atom+xml" href="http://www.insideria.com/atom.xml" />
  <id>tag:www.insideria.com,2009://34/tag:www.insideria.com,2009://34.35837-</id>
  <updated>2009-11-16T15:07:22Z</updated>
  <title>Comments for Calling JavaScript from Flex (http://www.insideria.com/2009/04/calling-javascript-from-flex.html)</title>
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.21-en</generator>
  <entry>
    <id>tag:www.insideria.com,2009://34.35837</id>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html" />
    <link rel="service.edit" type="application/atom+xml" href="http://blogs.oreilly.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=34/entry_id=35837" title="Calling JavaScript from Flex" />
    <published>2009-04-10T20:00:00Z</published>
    <updated>2009-08-09T19:59:01Z</updated>
    <title>Calling JavaScript from Flex</title>
    <summary>You might be surprised to know that Flex can create a JavaScript function and call it on the fly. For example, here is a snippet of ActionScript that shows how to obtain the URL of the page that invoked a...</summary>
    <author>
      <name>Mike Slinn</name>
      <uri>http://mslinn.com</uri>
    </author>
    
    <category term="Blogs" />
    
    <content type="html" xml:lang="en" xml:base="http://www.insideria.com/">
      <![CDATA[<p>You might be surprised to know that Flex can create a JavaScript function and call it on the fly.  For example, here is a snippet of ActionScript that shows how to obtain the URL of the page that invoked a Flex web application:</p><pre>import flash.external.ExternalInterface;<br />var href:String;<br />if (ExternalInterface.available)
&nbsp;&nbsp;&nbsp; href = ExternalInterface.call("function() { return location.href; }");</pre>
<p>The page hosting the Flex application does not need to have any such function defined; the Flex application creates an anonymous function on the fly and calls it, returning the result.  Most cool!</p><p>No FlashVars were harmed in the writing of this blog posting.</p>
<p>_______________________________</p>
<p>Mike Slinn<br />
Independent full-service software contractor and author<br />
<a href="http://slinnbooks.com/">http://slinnbooks.com</a><br />
<a href="http://www.mslinn.com/">http://mslinn.com</a></p>]]>
      
    </content>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35837-comment:2057347</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35837" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html#comment-2057347" />
    <title>Comment from teerasej on 2009-04-10</title>
    <author>
        <name>teerasej</name>
        <uri>http://flexblog.teerasej.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://flexblog.teerasej.com">
        <![CDATA[<p>Wow! this is very interesting! So I wonder, is it possible to call Javascript framework from this on the fly coding?</p>]]>
    </content>
    <published>2009-04-11T02:12:44Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35837-comment:2057405</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35837" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html#comment-2057405" />
    <title>Comment from radekg on 2009-04-12</title>
    <author>
        <name>radekg</name>
        <uri>http://gruchalski.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://gruchalski.com">
        <![CDATA[<p>@teerasej: of course it is, inside your function you can place whatever JS string you can think of. You can even load external JS on demand with document.createElement("script");</p>]]>
    </content>
    <published>2009-04-12T13:38:55Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35837-comment:2057447</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35837" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html#comment-2057447" />
    <title>Comment from Utkal R pradhan on 2009-04-12</title>
    <author>
        <name>Utkal R pradhan</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>This is already present in Curl, where you can call JavaScript functions and vice-versa ! </p>]]>
    </content>
    <published>2009-04-13T05:43:13Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35837-comment:2057456</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35837" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html#comment-2057456" />
    <title>Comment from bas on 2009-04-13</title>
    <author>
        <name>bas</name>
        <uri>http://www.zillizi.com/swfjavascript</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.zillizi.com/swfjavascript">
        <![CDATA[<p>There are some gotchas involved while executing code this way, especially when your javascript becomes a little more complex then the example above. We have a (commercial) product that takes care of these for you.</p>

<p>Thanks 4 listening!</p>]]>
    </content>
    <published>2009-04-13T09:40:47Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35837-comment:2057498</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35837" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html#comment-2057498" />
    <title>Comment from ariel sommeria on 2009-04-14</title>
    <author>
        <name>ariel sommeria</name>
        <uri>http://arielsommeria.com/blog/</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://arielsommeria.com/blog/">
        <![CDATA[<p>This works quite well, but not perfectly. For example it seems Internet Explorer doesn't do everything it should with ExternalInterface. I'm still digging at it...</p>]]>
    </content>
    <published>2009-04-14T09:58:13Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35837-comment:2057880</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35837" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html#comment-2057880" />
    <title>Comment from Lars on 2009-04-19</title>
    <author>
        <name>Lars</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Yes, neat and useful, but I'd say it's a feature of ActionScript and Flash Player rather than Flex, the Flex framework is not required for this.</p>

<p>ariel sommeria, perhaps the problem you encountered in IE is the know problem for the combination of SwfObject, a Flash within a form tag and ExternalInterface calls:</p>

<p><a href="http://www.google.com/search?q=externalinterface+ie+form+swfobject">http://www.google.com/search?q=externalinterface+ie+form+swfobject</a> </p>]]>
    </content>
    <published>2009-04-19T19:41:00Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2009://34.35837-comment:2083637</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2009://34.35837" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2009/04/calling-javascript-from-flex.html#comment-2083637" />
    <title>Comment from alchemist on 2009-09-04</title>
    <author>
        <name>alchemist</name>
        <uri>http://bytearray.brixtonjunkies.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://bytearray.brixtonjunkies.com">
        <![CDATA[<p>Another good example of Flex Javascript interaction <a href="http://bytearray.brixtonjunkies.com/2009/08/21/flex-externalinterface-the-flex-javascript-bridge/">http://bytearray.brixtonjunkies.com/2009/08/21/flex-externalinterface-the-flex-javascript-bridge/</a></p>]]>
    </content>
    <published>2009-09-04T22:11:07Z</published>
  </entry>

</feed
