<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Patricia Chan &#187; navigateToURL</title>
	<atom:link href="http://patriciachan.com/tag/navigatetourl/feed/" rel="self" type="application/rss+xml" />
	<link>http://patriciachan.com</link>
	<description>Multimedia Consultant, Canberra, AU</description>
	<lastBuildDate>Fri, 18 May 2012 01:57:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Action Script 2&#8242;s getURL equivalent in Action Script 3</title>
		<link>http://patriciachan.com/2010/04/action-script-2s-geturl-equivalent-in-action-script-3/</link>
		<comments>http://patriciachan.com/2010/04/action-script-2s-geturl-equivalent-in-action-script-3/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 01:43:35 +0000</pubDate>
		<dc:creator>Patricia Chan</dc:creator>
				<category><![CDATA[Geeky Stuff]]></category>
		<category><![CDATA[Action Script]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[AS3 class]]></category>
		<category><![CDATA[ExternalInterface]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[getURL]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[navigateToURL]]></category>

		<guid isPermaLink="false">http://patriciachan.com/?p=534</guid>
		<description><![CDATA[I have been helping a couple of clients migrating their existing Action Script 2 (AS2) flash assets/libraries to Action Script 3 (AS3). Amongst their many requirements, one of them is getting flash to talk to external javascript function. AS2: In AS2, you the simplest way is to use the getURL function. //Calling javascript of someFunction() that is embedded in the html page. getURL(&#8220;javascript:someFunction();&#8221;); You can also use the ExternalInterface class. import flash.external.*; ExternalInterface.call(&#8220;someFunction&#8221;); **or some variations of the above depending on the browser your client is using (hint: Browser bugs). AS3: As a general rule, you should use the ExternalInterface class to get your flash scripts to talk to other scripts. The code is very similar to AS2: import flash.external.* if (ExternalInterface.available) { &#160;&#160;&#160;ExternalInterface.call(&#8220;eval&#8221;, &#8220;someFunction();&#8221;); //Call the javascript function &#160;&#160;&#160;ExternalInterface.call(&#8220;eval&#8221;, &#8220;window.close();&#8221;); //Can also code js function &#160;&#160;&#160;ExternalInterface.call(&#8220;eval&#8221;, &#8220;window.opener.someFunction();&#8221;); //Call javascript function located in parent window } else { &#160;&#160;&#160;trace(&#8220;Oh No!&#8221;);// No external interface available } } More information: ExternalInteface However, if for some bizarre reason there is no link between your flash and the html page (a.k.a You are using Knowledge Presenter 7 to bring in flash assets into your eLearning program), the ExternalInterface may not work. Your alternative is to use navigateToURL function. var url:String = &#8220;JavaScript: gotoNextPause();&#8221;; var request:URLRequest = new URLRequest(url); try {    navigateToURL(request, &#8216;_self&#8217;);// second argument is target } catch (e:Error) {    trace(&#8220;Error occurred!&#8221;); } **Don&#8217;t forget to import all necessary classes. Point to remember: 1. External interface requires a link between your flash asset and the html page containing the javascript (e.g. your flash is embedded inside the html page). 2. If you need to directly call the javascript function, use getURL for AS2 and navigateToURL for AS3. Hopefully this will help some poor lost souls out there.]]></description>
		<wfw:commentRss>http://patriciachan.com/2010/04/action-script-2s-geturl-equivalent-in-action-script-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

