<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>code!</title>
	<atom:link href="http://active6.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://active6.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Wed, 17 Dec 2008 11:30:10 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='active6.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/156d8c4a3ec4ab83b58a53faaad798b8?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>code!</title>
		<link>http://active6.wordpress.com</link>
	</image>
			<item>
		<title>This blog is moving&#8230;</title>
		<link>http://active6.wordpress.com/2007/12/04/this-blog-is-moving/</link>
		<comments>http://active6.wordpress.com/2007/12/04/this-blog-is-moving/#comments</comments>
		<pubDate>Tue, 04 Dec 2007 18:13:01 +0000</pubDate>
		<dc:creator>Bob de Wit</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://active6.wordpress.com/2007/12/04/this-blog-is-moving/</guid>
		<description><![CDATA[I got more than a little tired of having to format code using no-plugin WordPress, so I set up my own.
Please check www.active6.com/blog.
       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=active6.wordpress.com&blog=530123&post=20&subd=active6&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I got more than a little tired of having to format code using no-plugin WordPress, so I set up my own.</p>
<p>Please check <a href="http://www.active6.com/blog">www.active6.com/blog.</a></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/active6.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/active6.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/active6.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/active6.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/active6.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/active6.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/active6.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/active6.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/active6.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/active6.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/active6.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/active6.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=active6.wordpress.com&blog=530123&post=20&subd=active6&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://active6.wordpress.com/2007/12/04/this-blog-is-moving/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c6dc87c6bb19e960e06b80642b4a29ec?s=96&#38;d=identicon" medium="image">
			<media:title type="html">active6</media:title>
		</media:content>
	</item>
		<item>
		<title>MySpace/GetURL Solution: Not Perfect, But Stylish</title>
		<link>http://active6.wordpress.com/2007/11/22/myspacegeturl-solution-not-perfect-but-stylish/</link>
		<comments>http://active6.wordpress.com/2007/11/22/myspacegeturl-solution-not-perfect-but-stylish/#comments</comments>
		<pubDate>Thu, 22 Nov 2007 13:13:02 +0000</pubDate>
		<dc:creator>Bob de Wit</dc:creator>
				<category><![CDATA[Flash*Flex*AS]]></category>
		<category><![CDATA[Macromedia Flash]]></category>

		<guid isPermaLink="false">http://active6.wordpress.com/2007/11/22/myspacegeturl-solution-not-perfect-but-stylish/</guid>
		<description><![CDATA[Note: this article is no longer maintained on this site.I got more than a little tired of having to format code using no-plugin WordPress, so I set up my own. For updates &#38; submitting comments, please check www.active6.com/blog 

Like most Flash developers, I was grinding my teeth when MySpace unilaterally decided to disable getURL() calls [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=active6.wordpress.com&blog=530123&post=19&subd=active6&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="color:#ff0000;"><strong>Note: this article is no longer maintained on this site.I got more than a little tired of having to format code using no-plugin WordPress, so I set up my own. For updates &amp; submitting comments, please check </strong></span><a href="http://www.active6.com/blog"><span style="color:#ff0000;"><strong>www.active6.com/blog </strong></span><br />
</a></p>
<p>Like most Flash developers, I was grinding my teeth when MySpace unilaterally decided to disable getURL() calls from Flash movies on their network. I was -and still am- convinced that the least MySpace could have done was to set up a program for Flash widget designers with good intentions in stead of hurling everyone back to the stone age (read: HTML links).</p>
<p>Today I finished a new artist site for MySpace and I decided to dig a little deeper into the problem. But first, maybe for those not familiar with the origin of the problem, a little overview.</p>
<p><span id="more-19"></span></p>
<p>Last year MySpace was attacked by a flash based worm. In response, MySpace has forced all flash movies to be played in version 9 of the Flash player. This version introduces several new network security features. The one relevant for the MySpace getURL issue is the parameters <strong>allowScriptAccess </strong>(already introduced in Flash player 6, but now enforced in version 9). MySpace disables links from flash including getURL by appending or overriding the following properties to your object tag:    <span style="color:#009900;"><a href="http://december.com/html/4/element/param.html"></a></span></p>
<ul>
<li><span style="color:#009900;"><a href="http://december.com/html/4/element/param.html"><span style="color:#000000;font-weight:bold;">&lt;param</span></a> <span style="color:#000066;">name</span>=<span style="color:#ff0000;">&#8220;allownetworking&#8221;</span> <span style="color:#000066;">value</span>=<span style="color:#ff0000;">&#8220;internal&#8221;</span> /<span style="color:#000000;font-weight:bold;">&gt;</span></span></li>
<li><span style="color:#009900;"><a href="http://december.com/html/4/element/param.html"><span style="color:#000000;font-weight:bold;">&lt;param</span></a> <span style="color:#000066;">name</span>=<span style="color:#ff0000;">&#8220;allowScriptAccess&#8221;</span> <span style="color:#000066;">value</span>=<span style="color:#ff0000;">&#8220;never&#8221;</span> /<span style="color:#000000;font-weight:bold;">&gt;</span></span></li>
<li><span style="color:#009900;"><a href="http://december.com/html/4/element/param.html"><span style="color:#000000;font-weight:bold;">&lt;param</span></a> <span style="color:#000066;">name</span>=<span style="color:#ff0000;">&#8220;enableJSURL&#8221;</span> <span style="color:#000066;">value</span>=<span style="color:#ff0000;">&#8220;false&#8221;</span> /<span style="color:#000000;font-weight:bold;">&gt;</span></span></li>
<li><span style="color:#009900;"><a href="http://december.com/html/4/element/param.html"><span style="color:#000000;font-weight:bold;">&lt;param</span></a> <span style="color:#000066;">name</span>=<span style="color:#ff0000;">&#8220;enableHREF&#8221;</span> <span style="color:#000066;">value</span>=<span style="color:#ff0000;">&#8220;false&#8221;</span> /&gt;</span></li>
</ul>
<p>Possible values of allowNetworking are:</p>
<ul>
<li>&#8220;all&#8221; (the default)&#8211;All networking APIs are permitted in the SWF.</li>
<li>&#8220;internal&#8221;&#8211;The SWF file may not call browser navigation or browser interaction APIs, listed later in this section, but it may call any other networking APIs. <strong>This one is enforced by MySpace.</strong></li>
<li>&#8220;none&#8221;&#8211;The SWF file may not call browser navigation or browser interaction APIs, listed later in this section, and it cannot use any SWF-to-SWF communication APIs, also listed later.</li>
</ul>
<p>Hence the getURL() problem. The command simply hits the security wall. Additional frustration is that the getURL() simply fails without any error being raised. Utterly frustrating.</p>
<p>So what can be done? Well, several people apparently tried write the &lt;embed&gt; code in such a way that the MySpace parser would be &#8220;tricked&#8221; into not inserting the tags. And although some of these attempts had success, each of these parser gaps was quickly nerfed by MySpace. No long-term solution there.</p>
<p>So let&#8217;s reverse the problem for a moment. In stead of focusing on what MySpace can block us from doing, what can MySpace NOT block without rendering all pages neolithic? Well, from that perspective, they can&#8217;t:</p>
<ul>
<li><strong>block Flash movies altogether</strong>. Bye galleries, music players, movie embedding? Don&#8217;t think so.</li>
<li><strong>block Flash movies from accessing files in the same domain</strong> for the same apparent reason.</li>
<li><strong>block basic HTML elements</strong>. &lt;div&gt;, &lt;a&gt; and &lt;img&gt; will always be there</li>
</ul>
<p>Given this shortlist, some people looking for a more permanent solution have come up with overlaying a &lt;div&gt; containing a transparent gif on the Flash movie, thus enabling a link. While this approach works fine for simple flash sites, what to do for really dynamic Flash sites where things move, appear and disappear all the time? Could we make the overlaying link dynamic in some way?</p>
<p>Yes we can, though it&#8217;s not perfect&#8230;but a Flash designer can certainly work it into his/her designs in such a way that it will look just like Flash.</p>
<p>Take a look at my <a href="http://myspace.com/carbonbass" target="_blank">artist site</a> &#8211; pop up the friends page, this will parse the friends list from MySpace and display this list in a Flash grid. Click on any of the icons, and you&#8217;ll see a link message appearing. Click on the link message and you&#8217;ll be taken to that profile. Come back, click another one in the friends list, click the link message again &#8211; you&#8217;re taken to the new profile you selected.</p>
<p>How does this work? Well, there&#8217;s three components: obviously an overlaying &lt;div&gt;, and 2 simple scripts. I&#8217;ve used PHP, but you can easily duplicate this in any other language.</p>
<p>Let&#8217;s start with the &lt;div&gt; part. Here&#8217;s the relevant code from my profile page:</p>
<p><span style="color:#0000ff;">&lt;object enableJSURL=&#8221;false&#8221; enablehref=&#8221;false&#8221; saveEmbedTags=&#8221;true&#8221;  	allowScriptAccess=&#8221;never&#8221;         allownetworking=&#8221;internal&#8221;  	type=&#8221;application/x-shockwave-flash&#8221;  	allowScriptAccess=&#8221;never&#8221; allownetworking=&#8221;internal&#8221;  	height=&#8221;750&#8243; width=&#8221;768&#8243;  	data=&#8221;http://sites.sitelinx.net/carbonbass/cb2008.swf&#8221;&gt;    	&lt;param name=&#8221;allowScriptAccess&#8221; value=&#8221;never&#8221; /&gt;    	&lt;param name=&#8221;allowNetworking&#8221; value=&#8221;internal&#8221; /&gt;    	&lt;param name=&#8221;movie&#8221; value=&#8221;http://sites.sitelinx.net/carbonbass/cb2008.swf&#8221; /&gt;    	&lt;param name=&#8221;quality&#8221; value=&#8221;high&#8221; /&gt;    	&lt;param name=&#8221;scale&#8221; value=&#8221;noscale&#8221; /&gt;    	&lt;param name=&#8221;bgcolor&#8221; value=&#8221;#000000&#8243; /&gt; </span><span style="color:#0000ff;"> </span> <span style="color:#0000ff;"> &lt;param name=&#8221;wmode&#8221; value=&#8221;transparent&#8221; /&gt;  &lt;/object&gt;</span></p>
<p>Notice the transparent wmode parameter. And then we add an overlaying transparent GIF on top of the Flash movie:</p>
<p><span style="color:#0000ff;">&lt;div style=&#8221;width: 350px; position: relative; top: -70px; left: -70px;&#8221;&gt;</span><br />
<span style="color:#ff0000;">&lt;a href=&#8221;http://sites.sitelinx.net/carbonbass/redirect.php&#8221;&gt;</span><br />
<span style="color:#0000ff;">&lt;img src=&#8221;http://x.myspace.com/images/clear.gif&#8221; border=&#8221;0&#8243; width=&#8221;350&#8243; height=&#8221;20&#8243;&gt; 	 	&lt;/a&gt;<br />
&lt;/div&gt;</span></p>
<p>As you can see, the transparent GIF links to a PHP script on my server called <strong>redirect.php</strong>. But how does the script know what to redirect to?</p>
<p>Well, even if we can&#8217;t do direct linking from our Flash file, nothing stops us from passing the desired link to a script that stores it into a session variable. Since this session is tied to the browser, all the redirect script would need to do is pick up the session variable and redirect the user to whatever is stored in that variable.</p>
<p>This implies passing the desired link from within your Flash movie to the redirect script. Here&#8217;s what happens in the Flash movie when you click on one of the friend icons in the list:</p>
<p><span style="color:#0000ff;">on (release)<br />
{<br />
</span></p>
<blockquote><p><span style="color:#0000ff;"> if (_root.MySpace == 1 )<br />
{<br />
</span></p>
<blockquote><p><span style="color:#0000ff;"> wcap = &#8220;Click here to visit &#8221; + this.caption.text;<br />
_root.ByPassCaption = wcap.toUpperCase();<br />
_root.ByPassLink._visible = true;<br />
wurl = &#8220;http://sites.sitelinx.net/carbonbass/setlink.php?url=&#8221; +  		escape( &#8220;http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&amp;friendID=&#8221; + this.id );<br />
LV = new LoadVars();<br />
LV.load( wurl  );<br />
</span></p></blockquote>
<p><span style="color:#0000ff;"> }<br />
else<br />
{<br />
</span></p>
<blockquote><p><span style="color:#0000ff;"> getURL( &#8220;http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&amp;friendid=&#8221; +  		this.id, &#8220;_blank&#8221; );<br />
</span></p></blockquote>
<p><span style="color:#0000ff;"> }<br />
</span></p></blockquote>
<p><span style="color:#0000ff;">}</span></p>
<p>The Flash script first determines wether is is running from a &#8220;normal&#8221; server or from MySpace. This can simply be done by passing a variable to the flash movie, like <span style="color:#ff0000;">src=&#8221;movie.swf?MySpace=0&#8243;</span>. For a normal server, it simply calls the getURL() script. In this way, you can use the same swf for your regular as well as for your MySpace site.</p>
<p>When running from myspace, the script creates a LoadVars object and calls the script <strong>setlink.php</strong>, passing the url the user selected. The essence of the script is extremely simple:</p>
<p><span style="color:#0000ff;">&lt;?php </span></p>
<blockquote><p><span style="color:#0000ff;">session_start(); </span></p>
<p><span style="color:#0000ff;">$url = $_REQUEST['url']; </span></p>
<p><span style="color:#0000ff;">$_SESSION['url'] = $url; </span></p></blockquote>
<p><span style="color:#0000ff;">?&gt;</span></p>
<p>It stores the passed url in the user&#8217;s session variable. Then all the redirect.php script does is pick up the url and jumps to it:</p>
<p><span style="color:#0000ff;">&lt;?php </span></p>
<blockquote><p><span style="color:#0000ff;">session_start(); </span></p>
<p><span style="color:#0000ff;">$url = $_SESSION['url']; </span></p>
<p><span style="color:#0000ff;">header(&#8220;Location: $url&#8221;); </span></p></blockquote>
<p><span style="color:#0000ff;">?&gt;</span></p>
<p>And there you have it &#8211; a dynamic HTML link overlay thanks to user session variables. Only drawback is you need to click twice. As I said: not perfect, but at least I can use dynamic links again in Flash on MySpace.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/active6.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/active6.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/active6.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/active6.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/active6.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/active6.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/active6.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/active6.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/active6.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/active6.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/active6.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/active6.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=active6.wordpress.com&blog=530123&post=19&subd=active6&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://active6.wordpress.com/2007/11/22/myspacegeturl-solution-not-perfect-but-stylish/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c6dc87c6bb19e960e06b80642b4a29ec?s=96&#38;d=identicon" medium="image">
			<media:title type="html">active6</media:title>
		</media:content>
	</item>
		<item>
		<title>AutoIT with Flex GUIs using the AS3 ExternalAPI</title>
		<link>http://active6.wordpress.com/2007/10/14/autoit-with-flex-guis-using-the-as3-externalapi/</link>
		<comments>http://active6.wordpress.com/2007/10/14/autoit-with-flex-guis-using-the-as3-externalapi/#comments</comments>
		<pubDate>Sun, 14 Oct 2007 21:11:46 +0000</pubDate>
		<dc:creator>Bob de Wit</dc:creator>
				<category><![CDATA[Flash*Flex*AS]]></category>

		<guid isPermaLink="false">http://active6.wordpress.com/2007/10/14/autoit-with-flex-guis-using-the-as3-externalapi/</guid>
		<description><![CDATA[Note: this article is no longer maintained on this site.I got more than a little tired of having to format code using no-plugin WordPress, so I set up my own. For updates &#38; submitting comments, please check www.active6.com/blog 
I recently started writing a clan tool for my kinship in the Lord Of The Rings Online [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=active6.wordpress.com&blog=530123&post=18&subd=active6&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="color:#ff0000;"><strong>Note: this article is no longer maintained on this site.I got more than a little tired of having to format code using no-plugin WordPress, so I set up my own. For updates &amp; submitting comments, please check </strong></span><a href="http://www.active6.com/blog"><span style="color:#ff0000;"><strong>www.active6.com/blog </strong></span></a></p>
<p>I recently started writing a clan tool for my kinship in the Lord Of The Rings Online (LOTRO) using the open source macro programming language AutoIT 3. As the GUI functions of this language are really limited and it&#8217;s very time-consuming to create even a simple GUI, I checked if there was a way to use Flex as the GUI. I ended up with something endlessly more versatile than what the Adobe AIR project allows with regard to interfacing with the Win32 API.</p>
<p>In this article I&#8217;ll go through the basic principles of SWF embedding into AI3, but bear in mind this principle can be applied to any development language that supports ActiveX embedding.</p>
<p><span id="more-18"></span><strong>About AutoIT</strong></p>
<p>AutoIt is a freeware Windows automation language written in C. It can be used to script most simple Windows-based tasks (great for PC rollouts or home automation). AutoIt has been in popular use since 1999 and continues to provide users and administrators with an easy way to script the Windows GUI. In February 2004 the latest version of AutoIt &#8211; known as AutoIt v3 &#8211; was released and added powerful scripting features.</p>
<p>AutoIt v3 was developed in a small team with the help of contributors around the world and this has led to a great set of help files, examples, support forum, mailing list, editor files, and third-party utilities.  Check out www.autoitscript.com</p>
<p><strong>About The ActionScript 3 External API </strong></p>
<p>This API is Flash 8&#8217;s  new replacement for <em>fscommand </em>and <em>setVariable </em>or <em>getURL. </em>Although primarily intended for flash-javascript communication, it&#8217;s perfect for embedded SWFs in applications. The ExternalInterface can be used to communicate from a Flash or Flex .swf file to <em>any</em> kind of a supported container. <strong>The ExternalInterface Class is only available from Flash 8 and above and will work only in Flash Player 8 and above. </strong></p>
<p>The External Interface API enables sending and receiving as many arguments as we want or none. With the old fscommand only 1 and at least 1 string could have been sent to an external function.The API supports arguments of the types: <em>Boolean, String, Number, Array, and Object. </em>XML is used as the transfer format.<em><br />
</em></p>
<p><strong>Calling AutoIT from Flex</strong></p>
<p>To call any external function, simply include the API library in your Flex (or Flash) project:</p>
<p><span style="color:#333399;"> import flash.external.ExternalInterface; </span></p>
<p>then call the externally defined function, for example to call the AI3 function CallAI3(Parameter), do as follows:</p>
<p><span style="color:#333399;"> ExternalInterface.call(&#8220;CallAI3&#8243;, Parameter );</span></p>
<p>Flex will call a function via the container called <em>FlashCall( ). </em>In AutoIt, you can set the function to be called from an ActiveX control with a prefix for the function like this:</p>
<p><span style="color:#333399;">$SinkObject=ObjEvent($oFlex, &#8220;Flex_&#8221;) ; </span></p>
<p>and then define the function as such:</p>
<p><span style="color:#333399;">Func Flex_FlashCall( $xml )</span></p>
<p><span style="color:#333399;">MsgBox( 1, &#8220;We received a call from Flex&#8221;, &#8220;Full XML:&#8221; &amp; $xml )</span></p>
<p><span style="color:#333399;">;In theory, we can now set return value(s) in XML format &#8211; however, in Flex this doesn&#8217;t seen to work.<br />
;So we can send whatever series of values as a separate result function call back to Flex.</span></p>
<p><span style="color:#333399;"><br />
$oFlex.CallFunction(&#8216;&lt;invoke name=&#8221;AI3CallReturn&#8221;&gt;&lt;arguments&gt;&lt;string&gt;This is the return value for your call to             FlashCall()&lt;/string&gt;&lt;/arguments&gt;&lt;/invoke&gt;&#8217;)</span></p>
<p><span style="color:#333399;"><br />
EndFunc</span></p>
<p><strong>Calling Flex From AutoIT</strong></p>
<p>As you can see, for the moment, the setting of return values does not seem to work in Flex. So we must define a callback entry in Flex for passing the return value the same way as for any Flex function being called. For example:</p>
<p><span style="color:#333399;"> ExternalInterface.addCallback( &#8220;AI3Call&#8221;, AI3Call );<br />
ExternalInterface.addCallback( &#8220;AI3CallReturn&#8221;, AI3CallReturn ); </span></p>
<p>Then simply define the function to be called and the return callback function:</p>
<p><span style="color:#333399;"> private function AI3Call( message:String )<br />
{<br />
doSomethingWith( message);<br />
}</span></p>
<p><span style="color:#333399;"> private function AI3CallReturn( message:String )<br />
{<br />
doSomethingWithReturnValue(message);<br />
}</span></p>
<p><strong>Complete AutoIT Code</strong></p>
<p><span style="color:#333399;">;Go into event capturing mode in stead of standard messaging mode<br />
Opt(&#8220;GUIOnEventMode&#8221;, 1)</span></p>
<p><span style="color:#333399;">;Set busy for GUI event loop<br />
global $busy = true</span></p>
<p><span style="color:#333399;">;External SWF File Name (assumed in same folder)<br />
$swffile = &#8220;externalAPI.swf&#8221;</span></p>
<p><span style="color:#333399;">;Create the Shockwave Flash Object &#8211; this can contain Flex as well as Flash SWF Files<br />
$oFlex = ObjCreate(&#8220;ShockwaveFlash.ShockwaveFlash&#8221;)</span></p>
<p><span style="color:#333399;">;Create the AutoIT GUI Window<br />
$hModWnd = GuiCreate(&#8220;Flex External API Demo&#8221;, 400, 400, -1, -1, -1  )</span></p>
<p><span style="color:#333399;">;Create the ActiveX Container<br />
$GUIActiveX = GUICtrlCreateObj( $oFlex, 0, 0 , 400, 400 )</span></p>
<p><span style="color:#333399;">;Set up event handling for Flex externalAPI calls<br />
$SinkObject=ObjEvent($oFlex, &#8220;Flex_&#8221;) ;</span></p>
<p><span style="color:#333399;">;Set up COM error handling<br />
$oMyError = ObjEvent(&#8220;AutoIt.Error&#8221;,&#8221;COMErrFunc&#8221;)</span></p>
<p><span style="color:#333399;">;Initialize the Flex ActiveX<br />
With $oFlex; Object tag pool<br />
.Movie = @scriptdir &amp; &#8216;\&#8217;&amp; $swffile;<br />
.ScaleMode = 3; 0 showall, 1 noborder, 2 exactFit, 3 noscale<br />
.bgcolor = &#8220;#000000&#8243;;<br />
.Loop = False<br />
.wmode = &#8220;Opaque&#8221;; Opaque / transparent<br />
.allowScriptAccess = &#8220;Always&#8221;<br />
EndWith</span></p>
<p><span style="color:#333399;">;Set close handler for AI GUI<br />
GUISetOnEvent($GUI_EVENT_CLOSE, &#8220;closeTest&#8221; )</span></p>
<p><span style="color:#333399;">;Show the GUI<br />
GUISetState ()</span></p>
<p><span style="color:#333399;">;Now call the Flex defined function AI3Call()<br />
$oFlex.CallFunction(&#8216;&lt;invoke name=&#8221;AI3Call&#8221;&gt;&lt;arguments&gt;&lt;string&gt;Hello Flex!&lt;/string&gt;&lt;/arguments&gt;&lt;/invoke&gt;&#8217;)</span></p>
<p><span style="color:#333399;">;Loop until closed<br />
while $busy<br />
sleep(10)<br />
WEnd</span></p>
<p><span style="color:#333399;">;The ExternalAPI Callback handler &#8211; the function that Flex will try to invoke is called FlashCall<br />
;We have defined &#8220;Flex_&#8221; as a prefix here: $SinkObject=ObjEvent($oFlex, &#8220;Flex_&#8221;) ;<br />
Func Flex_FlashCall( $xml )<br />
;Create an XML DOM Parser with the call XML string<br />
_XMLLoadXML( $xml )</span></p>
<p><span style="color:#333399;">;Get the invoked function name<br />
$invokedFunction = _XMLGetAttrib( &#8220;/invoke&#8221;, &#8220;name&#8221; )<br />
MsgBox( 1, &#8220;Invoked Function Name&#8221;, $invokedFunction )</span></p>
<p><span style="color:#333399;">;Get the first (and in this case the only) parameter<br />
$parameters = _XMLGetValue( &#8220;/invoke/arguments/string&#8221; )</span></p>
<p><span style="color:#333399;">MsgBox( 1, &#8220;We received a call from Flex&#8221;, &#8220;Invoked Function: &#8221; &amp; $invokedFunction &amp; @CRLF &amp; &#8220;Parameter: &#8221; &amp; $parameters[1] &amp; @CRLF &amp; &#8220;Full XML:&#8221; &amp; $xml )</span></p>
<p><span style="color:#333399;">;In theory, we can now set return value(s) in XML format &#8211; however, in Flex this doesn&#8217;t seen to work.<br />
;So we can send whatever series of values as a separate result function call back to Flex.<br />
$oFlex.CallFunction(&#8216;&lt;invoke name=&#8221;AI3CallReturn&#8221;&gt;&lt;arguments&gt;&lt;string&gt;This is the return value for your call to FlashCall()&lt;/string&gt;&lt;/arguments&gt;&lt;/invoke&gt;&#8217;)<br />
EndFunc</span></p>
<p><span style="color:#333399;">;Close GUI Event Handler<br />
Func closeTest()<br />
$busy = false<br />
GUIDelete()<br />
EndFunc</span></p>
<p><span style="color:#333399;">; COM error handler<br />
Func COMErrFunc()</span></p>
<p><span style="color:#333399;">Msgbox(0,&#8221;AutoItCOM Test&#8221;,&#8221;We intercepted a COM Error !&#8221;      &amp; @CRLF  &amp; @CRLF &amp; _<br />
&#8220;err.description is: &#8221;    &amp; @TAB &amp; $oMyError.description    &amp; @CRLF &amp; _<br />
&#8220;err.windescription:&#8221;     &amp; @TAB &amp; $oMyError.windescription &amp; @CRLF &amp; _<br />
&#8220;err.number is: &#8221;         &amp; @TAB &amp; hex($oMyError.number,8)  &amp; @CRLF &amp; _<br />
&#8220;err.lastdllerror is: &#8221;   &amp; @TAB &amp; $oMyError.lastdllerror   &amp; @CRLF &amp; _<br />
&#8220;err.scriptline is: &#8221;     &amp; @TAB &amp; $oMyError.scriptline     &amp; @CRLF &amp; _<br />
&#8220;err.source is: &#8221;         &amp; @TAB &amp; $oMyError.source         &amp; @CRLF &amp; _<br />
&#8220;err.helpfile is: &#8221;       &amp; @TAB &amp; $oMyError.helpfile       &amp; @CRLF &amp; _<br />
&#8220;err.helpcontext is: &#8221;    &amp; @TAB &amp; $oMyError.helpcontext _<br />
)</span></p>
<p><span style="color:#333399;">Local $err = $oMyError.number<br />
If $err = 0 Then $err = -1</span></p>
<p><span style="color:#333399;">SetError($err)  ; to check for after this function returns<br />
Endfunc</span></p>
<p><strong>Complete Flex Code</strong></p>
<p><span style="color:#333399;">&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br />
&lt;mx:Application xmlns:mx=&#8221;http://www.adobe.com/2006/mxml&#8221; layout=&#8221;absolute&#8221; creationComplete=&#8221;init()&#8221; width=&#8221;400&#8243; height=&#8221;400&#8243;&gt;<br />
&lt;mx:Script&gt;<br />
&lt;![CDATA[<br />
import mx.controls.Alert;<br />
import flash.external.ExternalInterface;</span></p>
<p><span style="color:#333399;">private function init():void<br />
{<br />
ExternalInterface.addCallback( "AI3Call", AI3Call );<br />
ExternalInterface.addCallback( "AI3CallReturn", AI3CallReturn );<br />
}</span></p>
<p><span style="color:#333399;">private function AI3Call( message:String )<br />
{<br />
this.response_tx.text = message;<br />
}</span></p>
<p><span style="color:#333399;">private function AI3CallReturn( message:String )<br />
{<br />
retval_tx.text = message;<br />
}</span></p>
<p><span style="color:#333399;">private function MoreInfo():void<br />
{<br />
navigateToURL(new URLRequest("http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00001971.html"), "_blank");<br />
}</span></p>
<p><span style="color:#333399;">private function SendToAI3():void<br />
{<br />
ExternalInterface.call("CallAI3", Send_tx.text );<br />
}</span></p>
<p><span style="color:#333399;">]]&gt;<br />
&lt;/mx:Script&gt;<br />
&lt;mx:TextArea x=&#8221;10&#8243; y=&#8221;28&#8243; width=&#8221;380&#8243; height=&#8221;72&#8243; id=&#8221;response_tx&#8221;/&gt;<br />
&lt;mx:TextInput x=&#8221;86&#8243; y=&#8221;118&#8243; width=&#8221;212&#8243; id=&#8221;Send_tx&#8221; text=&#8221;Hello AutoIT!&#8221;/&gt;<br />
&lt;mx:Button x=&#8221;306&#8243; y=&#8221;118&#8243; label=&#8221;Send&#8221; width=&#8221;84&#8243; click=&#8221;SendToAI3()&#8221;/&gt;<br />
&lt;mx:Label x=&#8221;10&#8243; y=&#8221;120&#8243; text=&#8221;Send Text&#8221; width=&#8221;68&#8243;/&gt;<br />
&lt;mx:Label x=&#8221;10&#8243; y=&#8221;10&#8243; text=&#8221;Receive Text from Calling AI Function&#8221; width=&#8221;380&#8243;/&gt;<br />
&lt;mx:Text x=&#8221;10&#8243; y=&#8221;266&#8243; text=&#8221;This example shows the basic comunication between a Flex Movie and an AutoIT3 ActiveX Container. It is more flexible than the Call() function and supports any combination of parameters sent back and forth using a simple XML format. This principle will also work for Flash 8 or higher movies, as it is pure ActionScript 3.0 on the SWF side. For more information on the AS3 externalAPI, click the link below.&#8221; width=&#8221;380&#8243; height=&#8221;104&#8243;/&gt;<br />
&lt;mx:LinkButton x=&#8221;10&#8243; y=&#8221;368&#8243; label=&#8221;Adobe ExternalAPI LiveDocs&#8221; width=&#8221;380&#8243; click=&#8221;{MoreInfo()}&#8221;/&gt;<br />
&lt;mx:TextArea x=&#8221;10&#8243; y=&#8221;172&#8243; width=&#8221;380&#8243; height=&#8221;73&#8243; id=&#8221;retval_tx&#8221;/&gt;<br />
&lt;mx:Label x=&#8221;10&#8243; y=&#8221;155&#8243; text=&#8221;Returned XML from Call to AI&#8221; width=&#8221;380&#8243;/&gt;<br />
&lt;mx:HRule x=&#8221;10&#8243; y=&#8221;253&#8243; width=&#8221;380&#8243; height=&#8221;5&#8243;/&gt;<br />
&lt;mx:HRule y=&#8221;108&#8243; right=&#8221;10&#8243; left=&#8221;10&#8243;/&gt;<br />
&lt;mx:HRule y=&#8221;149&#8243; left=&#8221;10&#8243; right=&#8221;10&#8243;/&gt;<br />
&lt;/mx:Application&gt;</span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/active6.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/active6.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/active6.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/active6.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/active6.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/active6.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/active6.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/active6.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/active6.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/active6.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/active6.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/active6.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=active6.wordpress.com&blog=530123&post=18&subd=active6&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://active6.wordpress.com/2007/10/14/autoit-with-flex-guis-using-the-as3-externalapi/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c6dc87c6bb19e960e06b80642b4a29ec?s=96&#38;d=identicon" medium="image">
			<media:title type="html">active6</media:title>
		</media:content>
	</item>
		<item>
		<title>Using the Wimpy Player in Flex</title>
		<link>http://active6.wordpress.com/2006/11/07/using-the-wimpy-player-in-flex/</link>
		<comments>http://active6.wordpress.com/2006/11/07/using-the-wimpy-player-in-flex/#comments</comments>
		<pubDate>Tue, 07 Nov 2006 15:11:56 +0000</pubDate>
		<dc:creator>Bob de Wit</dc:creator>
				<category><![CDATA[Flash*Flex*AS]]></category>

		<guid isPermaLink="false">http://active6.wordpress.com/2006/11/07/using-the-wimpy-player-in-flex/</guid>
		<description><![CDATA[Note: this article is no longer maintained on this site.I got more than a little tired of having to format code using no-plugin WordPress, so I set up my own. For updates &#38; submitting comments, please check www.active6.com/blog 
This one took some digging. The Wimpy Player uses the ActionScript 2.0 _root variable for configuration, and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=active6.wordpress.com&blog=530123&post=9&subd=active6&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="color:#ff0000;"><strong>Note: this article is no longer maintained on this site.I got more than a little tired of having to format code using no-plugin WordPress, so I set up my own. For updates &amp; submitting comments, please check </strong></span><a href="http://www.active6.com/blog"><span style="color:#ff0000;"><strong>www.active6.com/blog </strong></span></a></p>
<p><img src="http://active6.files.wordpress.com/2006/11/player.jpg" alt="player.jpg" align="left" />This one took some digging. The Wimpy Player uses the ActionScript 2.0 _root variable for configuration, and this has of course been deprecated in AS 3.0.</p>
<p>Wimpy expects some variables to be defined at _root level: the filename of the Wimpy Player (usually wimpy.swf) and the name of the wimpy Configuration XML file (wimpyConfigs.xml).</p>
<p>Since there is no way to pass this information from Flex through an Image or SWFloader element, I decided on using an intermediate Flash file, much like the WimpyLoader example that can be found on the Wimpy Site for embedding Wimpy into Flash. However, I wanted to construct it in such a way that anyone who doesn&#8217;t have Flash could use this Flex Loader without having to adjust the dimensions in the source file depending on the Wimpy Player skin used (and as a result, recompile the loader in Flash). You can see the result on my <a href="http://myspace.com/carbonbass">MySpace artist page<span id="more-9"></span></a>You will need my <a href="http://flex.active6.com/media/blogs/a/player.zip">preloader</a>. You can get a trial version of the Wimpy Player at <a href="http://www.wimpyplayer.com/">www.wimpyplayer.com</a>.</p>
<p>The following files need to be in the same folder as the Flex SWF File:</p>
<ul>
<li>The preloader (player.swf)</li>
<li>The Wimpy player (wimpy.swf)</li>
<li>The Wimpy Player skin and its resource files</li>
<li>The Wimpy Configuration file (wimpyConfigs.swf)</li>
</ul>
<h3>Controlling Wimpy</h3>
<p>Fortunately, all Wimpy controls can be set from the wimpyConfigs file. It will look something like this:</p>
<p><span style="color:#0000cc;">&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;wimpyConfigs version=&#8221;1.0&#8243;&gt;<br />
&lt;wimpySwf&gt;wimpy.swf&lt;/wimpySwf&gt;<br />
&lt;wimpyApp&gt;playlist.xml&lt;/wimpyApp&gt;<br />
&lt;wimpySkin&gt;skin_tube.xml&lt;/wimpySkin&gt;<br />
&lt;startupLogo&gt;no&lt;/startupLogo&gt;<br />
&lt;trackPlays&gt;    &lt;/trackPlays&gt;<br />
&lt;voteScript&gt;    &lt;/voteScript&gt;<br />
&lt;startPlayingOnload&gt;no&lt;/startPlayingOnload&gt;<br />
&lt;randomOnLoad&gt;    no&lt;/randomOnLoad&gt;<br />
&lt;shuffleOnLoad&gt;    no&lt;/shuffleOnLoad&gt;<br />
&lt;startOnTrack&gt;    &lt;/startOnTrack&gt;<br />
&lt;autoAdvance&gt;    yes&lt;/autoAdvance&gt;<br />
&lt;loopPlaylist&gt;    off&lt;/loopPlaylist&gt;<br />
&lt;popUpHelp&gt;      no&lt;/popUpHelp&gt;<br />
&lt;displayDownloadButton&gt;no&lt;/displayDownloadButton&gt;<br />
&lt;forceDownload&gt;    no&lt;/forceDownload&gt;<br />
&lt;scrollInfoDisplay&gt;  yes&lt;/scrollInfoDisplay&gt;<br />
&lt;infoDisplayTime&gt;  3&lt;/infoDisplayTime&gt;<br />
&lt;theVolume&gt;      100&lt;/theVolume&gt;<br />
&lt;bufferAudio&gt;    0&lt;/bufferAudio&gt;<br />
&lt;limitPlaytime&gt;    &lt;/limitPlaytime&gt;<br />
&lt;getMyid3info&gt;    no&lt;/getMyid3info&gt;<br />
&lt;serveMP3&gt;      no&lt;/serveMP3&gt;<br />
&lt;hide_folders&gt;    goodies,playlister_output,skins,getid3,_notes,_private,_private,_vti_bin,_vti_cnf,_vti_pvt,_vti_txt,cgi-bin&lt;/hide_folders&gt;<br />
&lt;hide_files&gt;    skin.xml,wimpyConfigs.xml&lt;/hide_files&gt;<br />
&lt;!&#8211; D:\dev\startdir &#8211;&gt;<br />
&lt;startDir&gt;      &lt;/startDir&gt;<br />
&lt;getid3libPath&gt;&lt;/getid3libPath&gt;<br />
&lt;defaultVisualBaseName&gt;coverart&lt;/defaultVisualBaseName&gt;<br />
&lt;defaultVisualExt&gt;  jpg&lt;/defaultVisualExt&gt;<br />
&lt;defaultImage&gt;    &lt;/defaultImage&gt;<br />
&lt;wimpyHTMLpageTitle&gt;Music&lt;/wimpyHTMLpageTitle&gt;<br />
&lt;tptBkgd&gt;      yes&lt;/tptBkgd&gt;<br />
&lt;bkgdColor&gt;      000000&lt;/bkgdColor&gt;<br />
&lt;forceXMLplaylist&gt;  no&lt;/forceXMLplaylist&gt;<br />
&lt;useSysCodePage&gt;  no&lt;/useSysCodePage&gt;<br />
&lt;ecommerce&gt;      no&lt;/ecommerce&gt;<br />
&lt;ecomWindow&gt;    _blank&lt;/ecomWindow&gt;<br />
&lt;icecast&gt;      &lt;/icecast&gt;<br />
&lt;useMysql&gt;      no&lt;/useMysql&gt;<br />
&lt;/wimpyConfigs&gt; </span></p>
<p>As you can see the wimpySWF, wimpyApp (the playlist) and the skin have been set to simple filenames so they need to be in the same folder. I&#8217;ve tried using URL&#8217;s, but I kept running into security sandbox errors, even if I allowed all domains in the Flash preloader file.</p>
<p>The rest of the configuration items in the wimpyConfigs.xml are not relevant to this article and can be explored in the Wimpy documentation.</p>
<h3>Getting Wimpy into Flex</h3>
<p>The essence of the Flex code looks like this:</p>
<p><span style="color:#0000cc;">&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br />
&lt;mx:Application horizontalScrollPolicy=&#8221;off&#8221; verticalScrollPolicy=&#8221;off&#8221; layout=&#8221;absolute&#8221; backgroundColor=&#8221;#000000&#8243; usePreloader=&#8221;true&#8221; xmlns:mx=&#8221;http://www.adobe.com/2006/mxml&#8221; xmlns:ns1=&#8221;*&#8221;&gt;</span></p>
<p><span style="color:#0000cc;">&lt;mx:Script&gt;<br />
&lt;![CDATA[</span></p>
<p><span style="color:#0000cc;">public var wimpyWidth:int = 244;<br />
public var wimpyHeight:int = 422;<br />
public var wimpyDefWidth:int = 480;<br />
public var wimpyDefHeight:int = 140;</span></p>
<p><span style="color:#0000cc;">Security.allowDomain( ["flex.active6.com","mymp3source.com"] );</span></p>
<p><span style="color:#0000cc;">public function initWimpy(): void<br />
{<br />
wimpy.scaleX = wimpyWidth/wimpyDefWidth;<br />
wimpy.scaleY = wimpyHeight/wimpyDefHeight;<br />
}</span></p>
<p><span style="color:#0000cc;">]]&gt;<br />
&lt;/mx:Script&gt;</span></p>
<p><span style="color:#0000cc;">&lt;mx:Image init=&#8221;{initWimpy()}&#8221; id=&#8221;wimpy&#8221; width=&#8221;480&#8243; height=&#8221;140&#8243; autoLoad=&#8221;true&#8221; scaleContent=&#8221;true&#8221; source=&#8221;player.swf&#8221; top=&#8221;100&#8243; right=&#8221;20&#8243;/&gt;</span></p>
<p><span style="color:#0000cc;">&lt;/mx:Application&gt; </span></p>
<p>OK, that&#8217;s not too difficult, is it? Let&#8217;s go over the main lines&#8230;</p>
<h3>We&#8217;ll need some dimensions</h3>
<p><span style="color:#0000cc;"> public var wimpyWidth:int = 244;<br />
public var wimpyHeight:int = 422;<br />
public var wimpyDefWidth:int = 480;<br />
public var wimpyDefHeight:int = 140; </span></p>
<p>I start by defining some size variables that we&#8217;ll need. The first two define the actual width and height of the skin that I&#8217;ll use for Wimpy (it&#8217;s the Tube skin readily available in the Wimpy skin download section). It&#8217;s dimensions are 244&#215;422.</p>
<p>The second dimensions are the default dimensions of the Wimpy player without any skin loaded. We&#8217;ll need these because we&#8217;re going to dynamically resize the Wimpy player movie within our Flex file because we don&#8217;t want to recompile the preloader every time.</p>
<h3>If you want to play MP3 files that are not on the same domain&#8230;</h3>
<p><span style="color:#0000cc;">Security.allowDomain( ["flex.active6.com","mymp3source.com"] );</span></p>
<p>This is needed because I&#8217;m going to pull in mp3&#8217;s from a fictuous site called mymp3source.com.</p>
<h3>Using an Image Tag to load Wimpy</h3>
<p><span style="color:#0000cc;">&lt;mx:Image init=&#8221;{initWimpy()}&#8221; id=&#8221;wimpy&#8221; width=&#8221;480&#8243; height=&#8221;140&#8243; </span></p>
<p><span style="color:#0000cc;"> autoLoad=&#8221;true&#8221; scaleContent=&#8221;true&#8221; source=&#8221;player.swf&#8221; top=&#8221;100&#8243; right=&#8221;20&#8243;/&gt; </span><br />
This defines a Flex Image component that will load the preloader (and the preloader will load Wimpy). The initial dimensions MUST be set to the default Wimpy width and height. When the preloader is initialized, we will call the initWimpy() function. scaleContent MUST be set to true.</p>
<h3>Getting Wimpy to resize properly</h3>
<p><span style="color:#0000cc;"> public function initWimpy(): void<br />
{<br />
wimpy.scaleX = wimpyWidth/wimpyDefWidth;<br />
wimpy.scaleY = wimpyHeight/wimpyDefHeight;<br />
} </span><br />
initWimpy() dynamically resizes the Wimpy player to the skin dimensions. You are wondering why we still need to do this even after we set scaleContent for the image to true? Well, it&#8217;s because the Wimpy Player is embedded into a movieClip in the preloader and redimensions itself based on the width and height it gets from the skin XML file. Redimensioning the preloader by setting its width and height does not trigger the embedded Wimpy player to resize. My guess would be that in the Wimpy code Stage.scaleMode is explicitly set. So you have to use scaleX/scaleY to get to PreLoader-&gt;Wimpy.</p>
<h3>Enjoy!</h3>
<p>And there you have it: a reusable preloader for Wimpy that doesn&#8217;t require recompiling to use another skin.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/active6.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/active6.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/active6.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/active6.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/active6.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/active6.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/active6.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/active6.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/active6.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/active6.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/active6.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/active6.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=active6.wordpress.com&blog=530123&post=9&subd=active6&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://active6.wordpress.com/2006/11/07/using-the-wimpy-player-in-flex/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c6dc87c6bb19e960e06b80642b4a29ec?s=96&#38;d=identicon" medium="image">
			<media:title type="html">active6</media:title>
		</media:content>

		<media:content url="http://active6.files.wordpress.com/2006/11/player.jpg" medium="image">
			<media:title type="html">player.jpg</media:title>
		</media:content>
	</item>
		<item>
		<title>Using the PEAR PHP XML Serializer class with Flex</title>
		<link>http://active6.wordpress.com/2006/11/06/using-the-pear-php-xml-serializer-class-with-flex/</link>
		<comments>http://active6.wordpress.com/2006/11/06/using-the-pear-php-xml-serializer-class-with-flex/#comments</comments>
		<pubDate>Mon, 06 Nov 2006 14:53:51 +0000</pubDate>
		<dc:creator>Bob de Wit</dc:creator>
				<category><![CDATA[Flash*Flex*AS]]></category>
		<category><![CDATA[PEAR]]></category>
		<category><![CDATA[PHP Programming]]></category>

		<guid isPermaLink="false">http://active6.wordpress.com/2006/11/06/using-the-pear-php-xml-serializer-class-with-flex/</guid>
		<description><![CDATA[Note: this article is no longer maintained on this site.I got more than a little tired of having to format code using no-plugin WordPress, so I set up my own. For updates &#38; submitting comments, please check www.active6.com/blog 
PEAR is a framework and distribution system for reusable PHP components. The code in PEAR is partitioned [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=active6.wordpress.com&blog=530123&post=5&subd=active6&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="color:#ff0000;"><strong>Note: this article is no longer maintained on this site.I got more than a little tired of having to format code using no-plugin WordPress, so I set up my own. For updates &amp; submitting comments, please check </strong></span><a href="http://www.active6.com/blog"><span style="color:#ff0000;"><strong>www.active6.com/blog </strong></span></a></p>
<p>PEAR is a framework and distribution system for reusable PHP components. The code in PEAR is partitioned in &#8220;packages&#8221;. Each package is a separate project with its own development team, version number, release cycle, documentation and a defined relation to other packages (including dependencies). Packages are distributed as gzipped tar files with a description file inside, and installed on your local system using the PEAR installer.PEAR contains PHP classes that are perfect for serializing data to be passed to a Flex application. Unfortunately, there is currently no package that would allow automatic installation for a Flex/PHP developer that wants to use the PEAR XML Serializer functionality.</p>
<p>In this article, I am going to describe how to do a local tweak and installation of the PEAR XML classes on a server that does not have PEAR pre-installed. Even if your server has PEAR installed, this approach will work.<span id="more-5"></span></p>
<h3>Getting the Necessary PEAR Files</h3>
<p>The PEAR files you will need for Flex are:</p>
<ul>
<li>PEAR.php</li>
<li>XML_Serializer.php &amp; XML_Unserializer.php</li>
<li>XML_Util.php</li>
</ul>
<p>You can obtain these from the PEAR Package listings, but I have attached the modified files for you <a title="Modified PEAR XML Files" href="http://www.active6.com/code/modified_pear_xml.zip" target="_blank">here</a>.</p>
<h3>Modifying the Include Statements</h3>
<p>If you do not wish to reproduce the PEAR Package folder structure, you must edit the XML_Serializer.php and XML_Unserializer.php files for the path of the PEAR library:</p>
<p><span style="color:#0000cc;">/**<br />
* uses PEAR error management<br />
*/<br />
require_once &#8216;PEAR.php&#8217;;</span></p>
<p><span style="color:#0000cc;">/**<br />
* uses XML_Util to create XML tags<br />
*/<br />
require_once &#8216;XML_Util.php&#8217;; </span></p>
<h3>Introducing the Serializer Class</h3>
<p>The XML_Serializer.php contains a class definition that allows for a wide range of XML files to be generated from PHP variables, arrays and objects. The generation mode is controlled by passing an array of parameters that is passed to the constructor of the class.</p>
<p>The most important parameters you should include are the <em>overall container tag </em>of the XML data and the <em>item tag name</em>.</p>
<h3>Application Example</h3>
<p>Let&#8217;s take an example. I&#8217;ve been working on something like this for the MySpace Page of a record label. Let&#8217;s say you want to display a list of your MySpace friends in your Flex application. You have a MySQL table with all your friends data, such as:</p>
<ul>
<li>Friend Number</li>
<li>Friend Name</li>
<li>Image</li>
<li>etc</li>
</ul>
<h3>Getting the Friends data From MySQL</h3>
<p>We would load this data into an array of objects in a PHP script called getfriends.php using the following code:</p>
<p><span style="color:#0000cc;">//Connect to MySQL, assuming we have already<br />
//defined the Database Login Parameters as constants<br />
$dbLink = mysql_pconnect(DB_HOST, DB_USER, DB_PW);</span></p>
<p><span style="color:#0000cc;">//Create an array to hold the friends query result<br />
$friendsList = array();</span></p>
<p><span style="color:#0000cc;">//Execute the MySQL Query and process into an array<br />
$sql = &#8220;SELECT * FROM friends&#8221;;<br />
$result = mysql_query($sql, $dbLink);<br />
if ($result)<br />
{<br />
while ($row = mysql_fetch_object($result))<br />
{<br />
array_push($friendsList, $row);<br />
}<br />
mysql_free_result($result);<br />
}</span></p>
<h3>Creating the Flex Request and Tile Display</h3>
<p>We would create a HTTP Request tag in our Flex application like this:</p>
<p><span style="color:#0000cc;">&lt;mx:HTTPService id=&#8221;friendslist&#8221;<br />
url=&#8221;http://localhost/MySpace/php/getfriends.php&#8221;<br />
useProxy=&#8221;false&#8221;<br />
method=&#8221;GET&#8221;<br />
result=&#8221;friendHandler(event)&#8221;&gt;<br />
&lt;/mx:HTTPService&gt;</span></p>
<p>And create a TileList to display the friends data:</p>
<p><span style="color:#0000ff;">&lt;mx:Panel id=&#8221;FriendsListPanel&#8221; title=&#8221;MySpace Friends&#8221;&gt;<br />
&lt;mx:TileList direction=&#8221;vertical&#8221;<br />
columnCount=&#8221;1&#8243;<br />
rowHeight=&#8221;120&#8243;<br />
dataProvider=&#8221;{friendslist.lastResult.friends.friend}&#8221;<br />
id=&#8221;FriendsTileList&#8221;<br />
itemRenderer=&#8221;FriendListItem&#8221; /&gt;<br />
&lt;/mx:Panel&gt; </span></p>
<h3>Where it comes together: the dataProvider</h3>
<p>As you can see, the TitleList uses the following dataProvider:</p>
<p><span style="color:#0000cc;"><em>friendslist.lastResult.friends.friend</em></span></p>
<p>This means the expected XML format would be something like:</p>
<p><span style="color:#0000cc;">&lt;friends&gt;<br />
&lt;friend&gt;<br />
&lt;id&gt;51930230&lt;/id&gt;<br />
&lt;userid&gt;Derrick May&lt;/userid&gt;<br />
&lt;fullid&gt;derrickmay&lt;/fullid&gt;<br />
&lt;fullname&gt;Derrick May&lt;/fullname&gt;<br />
&lt;styles&gt;Techno / House / Club&lt;/styles&gt;<br />
&lt;friendcount&gt;14536&lt;/friendcount&gt;<br />
&lt;visitcount&gt;64247&lt;/visitcount&gt;<br />
&lt;lastlogin&gt;2006-10-11&lt;/lastlogin&gt;<br />
&lt;image&gt;http://myspace-728.vo.llnwd.net/01007/82/77/1007837728_s.jpg&lt;/image&gt;<br />
&lt;city&gt;DETROIT&lt;/city&gt;<br />
&lt;state&gt;Michigan&lt;/state&gt;<br />
&lt;country&gt;US&lt;/country&gt;<br />
&lt;joined&gt;2006-01-27&lt;/joined&gt;<br />
&lt;/friend&gt;<br />
&lt;friend&gt;<br />
&lt;id&gt;63740153&lt;/id&gt;<br />
&lt;userid&gt;Plastikman&lt;/userid&gt;<br />
&lt;fullid&gt;plastikman&lt;/fullid&gt;<br />
&lt;fullname&gt;Plastikman&lt;/fullname&gt;<br />
&lt;styles&gt;Techno / Electronica / Ambient&lt;/styles&gt;<br />
&lt;friend&gt;1&lt;/friend&gt;<br />
&lt;friendcount&gt;12955&lt;/friendcount&gt;<br />
&lt;visitcount&gt;52482&lt;/visitcount&gt;<br />
&lt;lastlogin&gt;2006-10-11&lt;/lastlogin&gt;<br />
&lt;image&gt;http://myspace-786.vo.llnwd.net/00577/68/77/577847786_s.jpg&lt;/image&gt;<br />
&lt;city&gt;Windsor&lt;/city&gt;<br />
&lt;state&gt;Ontario&lt;/state&gt;<br />
&lt;country&gt;Canada&lt;/country&gt;<br />
&lt;joined&gt;2006-03-18&lt;/joined&gt;<br />
&lt;/friend&gt;<br />
&lt;/friends&gt; </span></p>
<h3>Getting the PEAR XML Serializer to generate the expected XML</h3>
<p>In order to have the XML class generate code from our getfriends.php result array we initialize a Serializer with the following options and have it generate the XML based on the $friendsList array:</p>
<p><span style="color:#0000cc;">$options = array(<br />
XML_SERIALIZER_OPTION_XML_DECL_ENABLED  =&gt; false,<br />
XML_SERIALIZER_OPTION_DOCTYPE_ENABLED  =&gt; false,<br />
XML_SERIALIZER_OPTION_INDENT            =&gt; &#8221;    &#8220;,<br />
XML_SERIALIZER_OPTION_LINEBREAKS        =&gt; &#8220;\n&#8221;,<br />
XML_SERIALIZER_OPTION_TYPEHINTS         =&gt; false,<br />
XML_SERIALIZER_OPTION_XML_ENCODING      =&gt; &#8220;UTF-8&#8243;,<br />
XML_SERIALIZER_OPTION_ROOT_NAME    =&gt; &#8220;friends&#8221;,<br />
XML_SERIALIZER_OPTION_DEFAULT_TAG  =&gt; &#8220;friend&#8221;<br />
);</span></p>
<p><span style="color:#0000cc;">//Instatiate the serializer object<br />
$serializer = new XML_Serializer($options);<br />
$serializer-&gt;setErrorHandling(PEAR_ERROR_DIE);</span></p>
<p><span style="color:#0000cc;">//Serialze the data<br />
$result = $serializer-&gt;serialize($array, &#8216;friend&#8217;);<br />
$xml = $serializer-&gt;getSerializedData();</span></p>
<p><span style="color:#0000cc;">//Return the xml to the Flex application<br />
echo( $xml ); </span></p>
<p>And that&#8217;s all there&#8217;s to it.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/active6.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/active6.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/active6.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/active6.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/active6.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/active6.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/active6.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/active6.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/active6.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/active6.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/active6.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/active6.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=active6.wordpress.com&blog=530123&post=5&subd=active6&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://active6.wordpress.com/2006/11/06/using-the-pear-php-xml-serializer-class-with-flex/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c6dc87c6bb19e960e06b80642b4a29ec?s=96&#38;d=identicon" medium="image">
			<media:title type="html">active6</media:title>
		</media:content>
	</item>
		<item>
		<title>Flex / PHP Security Basics &#8211; Part One</title>
		<link>http://active6.wordpress.com/2006/11/05/flex-php-security-basics-part-one/</link>
		<comments>http://active6.wordpress.com/2006/11/05/flex-php-security-basics-part-one/#comments</comments>
		<pubDate>Sun, 05 Nov 2006 14:53:49 +0000</pubDate>
		<dc:creator>Bob de Wit</dc:creator>
				<category><![CDATA[Flash*Flex*AS]]></category>
		<category><![CDATA[PHP Programming]]></category>

		<guid isPermaLink="false">http://active6.wordpress.com/2006/11/08/flex-php-security-basics-part-one/</guid>
		<description><![CDATA[Note: this article is no longer maintained on this site.I got more than a little tired of having to format code using no-plugin WordPress, so I set up my own. For updates &#38; submitting comments, please check www.active6.com/blog 
I&#8217;ve been creating Flash / PHP web sites and applications for years, but I am relatively new [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=active6.wordpress.com&blog=530123&post=4&subd=active6&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><span style="color:#ff0000;"><strong>Note: this article is no longer maintained on this site.I got more than a little tired of having to format code using no-plugin WordPress, so I set up my own. For updates &amp; submitting comments, please check </strong></span><a href="http://www.active6.com/blog"><span style="color:#ff0000;"><strong>www.active6.com/blog </strong></span></a></p>
<p>I&#8217;ve been creating Flash / PHP web sites and applications for years, but I am relatively new to Flex. After browsing the Adobe PHP samples for Flex earlier this week, I couldn&#8217;t help but notice that some of this code could prove extremely hazardous if used in a public Flex site. This is no criticism, but since these examples will be read by virtually anyone who want to use the PHP / Flex tandem, it&#8217;s probably not a bad idea to go over the security basics. I just love PHP. It&#8217;s a great language for rapid development of dynamic site and application backends. Combined with the RIA power of Flex 2, there&#8217;s no end to what you can do. But &#8211; as for every web programming language, security considerations for designing even the simplest web sites with Flex and PHP are crucial and often overlooked.<span id="more-4"></span> This article makes some assumptions that on first look may linger on paranoia, but you should always remember the following when developing PHP / Flex apps:</p>
<ul>
<li><span style="color:#cc0000;">It&#8217;s dead easy to decompile a Flex or Flash file. The file format is public and many decompilers exist.</span></li>
<li><span style="color:#cc0000;">It&#8217;s equally easy to monitor requests and results from a Flex app to and from the server. This and the above make it a breeze to get the URI&#8217;s and expected parameters for your PHP scripts.</span></li>
<li><span style="color:#cc0000;">Most Flex/PHP tandem applications will expect and return clean, simple XML data. This data can be parsed easily to see if any security holes can be exploited.</span></li>
</ul>
<p>Many PHP features can lead to security holes. The PHP.net site as well as independent security initiatives (such as phpsec.org, the PHP Security Consortium) have identified a small dozen of &#8220;Top Security Blunders&#8221; that keep popping up. We&#8217;ll go over these from a Flex perspective in this article. Understanding each possible flaw will help you avoid making the same mistakes in your PHP applications.</p>
<h3>Unvalidated User Input</h3>
<p>This may seem paranoid &#8211; but one of the most important rules of thumb for web development is that any data sent by a user should be considered as potentially malicious. Ignoring this leads to most of the exploits we&#8217;ll review. Let&#8217;s say we want construct a login panel. I&#8217;ve removed the unessential layout code:</p>
<p><span style="color:#0000cc;">&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br />
&lt;mx:Panel xmlns:mx=&#8221;http://www.adobe.com/2006/mxml&#8221; title=&#8221;Login Form&#8221;&gt;</span></p>
<p><span style="color:#0000cc;">&lt;mx:Label text=&#8221;User ID:&#8221; /&gt;<br />
&lt;mx:TextInput id=&#8221;userid&#8221; editable=&#8221;true&#8221; enabled=&#8221;true&#8221; /&gt;</span></p>
<p><span style="color:#0000cc;">&lt;mx:Label text=&#8221;Password&#8221; /&gt;<br />
&lt;mx:TextInput id=&#8221;password&#8221; displayAsPassword=&#8221;true&#8221; editable=&#8221;true&#8221; enabled=&#8221;true&#8221; /&gt;<br />
&lt;mx:Button label=&#8221;Login&#8221; id=&#8221;buttonLogin&#8221; enabled=&#8221;true&#8221; click=&#8221;buttonLoginClick();&#8221; /&gt;</span></p>
<p><span style="color:#0000cc;">&lt;mx:HTTPService id=&#8221;userLogin&#8221; url=&#8221;http://localhost/flex/php/login.php&#8221; useProxy=&#8221;false&#8221; method=&#8221;POST&#8221; result=&#8221;userLoginHandler(event)&#8221;&gt;<br />
&lt;mx:request xmlns=&#8221;"&gt;<br />
&lt;userid&gt;{userid.text}&lt;/userid&gt;&lt;password&gt;{password.text}&lt;/password&gt;<br />
&lt;/mx:request&gt;<br />
&lt;/mx:HTTPService&gt;</span></p>
<p><span style="color:#0000cc;">&lt;mx:Script&gt;<br />
&lt;![CDATA[<br />
import mx.rpc.events.ResultEvent;<br />
import mx.controls.Alert;</span></p>
<p><span style="color:#0000cc;">private function userLoginHandler(event:ResultEvent):void<br />
{<br />
if ( event.result.userLogin.loginresult == 0 )<br />
{<br />
Alert.show( "Login Failed" );<br />
}<br />
else<br />
{<br />
Alert.show( "Login Succeeded" );<br />
}<br />
}</span></p>
<p><span style="color:#0000cc;">private function buttonLoginClick(): void<br />
{<br />
userLogin.send();<br />
}<br />
]]&gt;<br />
&lt;/mx:Script&gt;<br />
&lt;/mx:Panel&gt;</span></p>
<p align="left">and here&#8217;s the corresponding simplified login.php code:</p>
<p align="left"><span style="color:#0000cc;"> &lt;?php</span><br />
<span style="color:#0000cc;"> $search= $_REQUEST['search'];</span></p>
<p><span style="color:#0000cc;"> $dir= dir( $search );</span><br />
<span style="color:#0000cc;"> &#8230;</span><br />
<span style="color:#0000cc;"> ?&gt;</span><br />
<span style="color:#0000cc;"> </span></p>
<p><span style="color:#0000cc;"><span style="color:#000000;">This PHP code is not secure. The $_REQUEST variable is assigned without any validation. A malicious user might append something like &#8220;<span style="color:#cc0000;">;rm -rf *</span>&#8221; and delete your web site folder. You must ensure that the user input is valid and nothing more than what is expected. Do not only use Flex-based validation for this: there are many HTTP monitors and SWF decompilers readily available to hackers that permit modifying your Flex file. You need to add PHP code to ensure that the information the user provides is valid, like so: </span></span></p>
<p><span style="color:#0000cc;"><br />
</span><span style="color:#0000cc;">&lt;?php<br />
</span><span style="color:#0000cc;"> $search= escapeshellcmd($_REQUEST['search']);<br />
?&gt;</span></p>
<p><span style="color:#0000cc;"><span style="color:#000000;">escapeshellcmd() escapes any characters in a string that might be used to trick a shell command into executing arbitrary commands.</span></span></p>
<h3><span style="color:#0000cc;"><span style="color:#000000;">SQL Injection </span></span></h3>
<p><span style="color:#0000cc;"><span style="color:#000000;">SQL injection is another type of unvalidated user input. It allows exploitation of a database query. For example, you would check a userid/password set received against a user table. In MySQL, this would look something like: </span><br />
</span></p>
<p align="left"><span style="color:#0000cc;"> SELECT * FROM users WHERE userid=&#8217;$userid&#8217; AND password=&#8217;$password&#8217;;</span><br />
<span style="color:#0000cc;"> </span></p>
<p><span style="color:#000000;">A malicious user could enter &#8220;admin&#8221; as the userid and the following as his password:</span></p>
<p align="left"><span style="color:#000000;"><span style="color:#0000cc;">&#8216; OR &#8216;1&#8242;=&#8217;1</span></span><br />
<span style="color:#000000;"> </span></p>
<p><span style="color:#000000;">This results in the following query:<br />
<span style="color:#0000cc;"><br />
</span></span></p>
<p align="left"><span style="color:#000000;"><span style="color:#0000cc;">SELECT * FROM users WHERE name=&#8217;admin&#8217; AND pass=&#8217;<span style="color:#cc0000;">&#8216; OR &#8216;1&#8242;=&#8217;1&#8242;;</span></span></span><br />
<span style="color:#000000;"> </span></p>
<p><span style="color:#000000;">This bypasses validating the password &#8211; the user has gained entry as the administrator. We need to neutralize malicious entries from the submitted values. In many PHP installations, this is already taken care of by the magic_quotes_gpc setting in the php.ini file. You can check this by using the phpinfo() function. In case magic quotes is set to Off, you must use PHP&#8217;s addslashes() function:</span></p>
<p align="left"><span style="color:#000000;"><span style="color:#0000cc;">$userid = addslashes($_REQUEST['userid']);</span></span><br />
<span style="color:#000000;"><span style="color:#0000cc;"> $password = addslashes($_REQUEST['password']);</span></span><br />
<span style="color:#000000;"><span style="color:#0000cc;"> </span></span></p>
<p><span style="color:#000000;">However, there is one unfortunate side-effects to this setting being enabled: every value passed back to your PHP scripts will have slashes added. I won&#8217;t go into a discussion on what is the best setting here, because it really depends on the system you&#8217;re building. (You can check the PHP documentation for details).</span></p>
<p><span style="color:#000000;">As a rule of thumb, always check the status of magic_quotes_gpc and, if it is turned on, pass all input through PHP&#8217;s stripslashes() function. Then apply addslashes() to values for use in database queries.</span></p>
<p align="left"><span style="color:#000000;"><span style="color:#0000cc;">if (get_magic_quotes_gpc())</span></span></p>
<p align="left"><span style="color:#000000;"><span style="color:#0000cc;">{ </span></span></p>
<p align="left"><span style="color:#000000;"><span style="color:#0000cc;"> $_REQUEST = array_map(&#8217;stripslashes&#8217;, $_REQUEST);</span></span><br />
<span style="color:#000000;"><span style="color:#0000cc;"> }</span></span><br />
<span style="color:#000000;"><span style="color:#0000cc;"> </span><br />
SQL injection also allows malicious users to get to your database records. Always check (case-insensitive!) data that will be used in a query for the characters &#8216;&#8221;,;() and for keywords like &#8220;FROM&#8221;, &#8220;LIKE&#8221;, and &#8220;WHERE&#8221;.<br />
</span></p>
<p><span style="color:#000000;">OK, that concludes the first part of this article. In part two, we&#8217;ll go into some other potential security holes like error reporting and safe mode.<br />
</span></p>
<p><span style="color:#000000;"> </span></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/active6.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/active6.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/active6.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/active6.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/active6.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/active6.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/active6.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/active6.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/active6.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/active6.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/active6.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/active6.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=active6.wordpress.com&blog=530123&post=4&subd=active6&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://active6.wordpress.com/2006/11/05/flex-php-security-basics-part-one/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c6dc87c6bb19e960e06b80642b4a29ec?s=96&#38;d=identicon" medium="image">
			<media:title type="html">active6</media:title>
		</media:content>
	</item>
	</channel>
</rss>