<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>SnippetRepoBrowser</title>
    <link>http://snippet.gnstudio.com/snippetrepobrowser/index</link>    
    <description>RSS Feed of SnippetRepoBrowser (Global RSS)</description>    
    <language>en-us</language>
    <pubDate>Thu, 09 Feb 2012 21:34:52 +0100</pubDate>
    <docs>SnippetRepoBrowser/index</docs>
    <generator>SnippetRepoBrowser Feed Generator</generator>
    <item>
      <title><![CDATA[Define and call javascript functions directly inside an AS3 class (FL / FX)]]></title>
      <link>http://snippet.gnstudio.com/viewtopic/17</link>
      <description><![CDATA[ActionScript 3.0 doesn&#39;t manage all developers needs, so often they have to use other languages, as <span style="font-style:italic">JavaScript</span>, to accomplish some operations like <span style="font-weight:bold">open an HTML popup</span> or get the <span style="font-weight:bold">userAgent</span> property, useful to know the user Browser. <br />The <span style="font-style:italic">AS3 ExternalInterfac</span>e class allow to invoke <span style="font-style:italic">Javascript</span> functions directly from Flash. <br />Usually these functions are defined inside the HTML page but in this sample we&#39;ll see how to implement them inside an ActionScript class, avoiding to edit HTML code. <br /><br /><span style="font-weight:bold"><span style="color: green">USAGE:</span> <br /></span><br />import com.fabiobiondi.utils.URLUtil; <br />1) URLUtil.checkBrowser() <br />2) URLUtil.openWindow( &#39;<a href="http://www.google.com&#39;" target="_blank">http://www.google.com&#39;</a>, &#39;_blank&#39;, &#39;width=400,height=200,scrollbars=yes&#39;)<br />]]><![CDATA[<div class="divcode"><pre lang="actionscript">package com.fabiobiondi.utils {<br /> <br />    import flash.external.ExternalInterface;<br /> <br />    public class URLUtil    {<br /> <br />	/**<br />	 * Open a popup window<br />	 * @param	url			link to open<br />	 * @param	target		window target<br />	 * @param	options 	popup options<br />	 * <br />	 */<br />        public static function openWindow( url : String, <br />        				    target : String = &quot;_blank&quot;, <br />        				    options : String = &quot;&quot;) : void {<br /> <br />            ExternalInterface.call(&quot;window.open&quot;, url, target, options);<br />        }<br /> <br /> <br />	/**<br />	 * Get the Browser Type<br />	 * @Return the userAgent property	<br />	 * <br />	 */<br />	public static function checkBrowser():String {<br /> <br />		var userAgent:String = <br />			String(ExternalInterface.call(&quot;function() {return navigator.userAgent;}&quot;));<br /> <br />		return userAgent;<br /> <br /> <br />	}<br /> <br /> <br />    }<br /> <br />}</pre></div><br /><br />]]></description>
      <author>flagers</author>
      <pubDate>Mon, 14 Sep 2009 02:57:26 +0200</pubDate>
      <category>ActionScript</category>
      <guid>http://snippet.gnstudio.com/viewtopic/17</guid>
   </item>
  </channel>
</rss>
