<?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>Lambda</title>
	<atom:link href="http://sroucheray.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://sroucheray.org/blog</link>
	<description>Stephane Roucheray's trivial work and thoughts</description>
	<lastBuildDate>Tue, 23 Feb 2010 20:44:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to insert a SWF file in an ASDoc API documentation ?</title>
		<link>http://sroucheray.org/blog/2010/02/how-to-insert-a-swf-file-in-an-asdoc-api-documentation/</link>
		<comments>http://sroucheray.org/blog/2010/02/how-to-insert-a-swf-file-in-an-asdoc-api-documentation/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 15:22:49 +0000</pubDate>
		<dc:creator>Stéphane Roucheray</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[asdoc]]></category>
		<category><![CDATA[swf]]></category>

		<guid isPermaLink="false">http://sroucheray.org/blog/?p=605</guid>
		<description><![CDATA[
ASDoc API documentation is well designed for developers but remain difficult to read for others. Some of my co-workers are web designer. They code a bit but they want API to be simple and they want usage examples. In the past days I developed some image filters and effects for them. The resulting API has [...]]]></description>
			<content:encoded><![CDATA[<p><img width="550" src="http://sroucheray.org/blog/wp-content/uploads/2010/02/ASDocScanlineEffect.jpg" alt="ASDoc with inline SWF file" /></p>
<p>ASDoc API documentation is well designed for developers but remain difficult to read for others. Some of my co-workers are web designer. They code a bit but they want API to be simple and they want usage examples. In the past days I developed some image filters and effects for them. The resulting API has very few meaning without a real example of code and a way to test it. Thus, I wanted them to be able to access the code examples as well as being able to test the result of each effects, inline, in the ASDoc documentation. Click the image below to see the rendering SWF tester.</p>
<p><a href="http://sroucheray.org/blog/wp-content/uploads/2010/02/effectTester.swf" rel="shadowbox;height=780;width=1000"><img src="http://sroucheray.org/blog/wp-content/uploads/2010/02/effectTester.jpg" alt="Effect tester" /></a></p>
<p>Code examples are easy to integrate using the <span class="pre">@example</span> and <span class="pre">@includeExample</span> (<a href="http://help.adobe.com/en_US/Flex/4.0/html/WSd0ded3821e0d52fe1e63e3d11c2f44bc36-7ff6.html">Flex 4</a>), but there is no default way of inserting SWF files directly (as far as I know).</p>
<p>In order to insert a SWF file in a generated ASDoc API documentation, one needs to understand the process of generating documentation with ASDoc. On one side there are packages and classes, on the other side ASDoc templates files. Generating documentation consists for the <span class="pre">asdoc.exe</span> application of parsing the classes for any special comments and injecting what has been found in the templates. The result is output in a directory and is made of a bunch of HTML, CSS, JavaScript files&#8230;</p>
<p>The type of special comments the ASDoc process is looking for looks like that :</p>
<div class="codecolorer-container actionscript dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">/**<br />
&nbsp;* Apply an RGB distortion effect on a DisplayObject<br />
&nbsp;* <br />
&nbsp;* @param target The DisplayObject on which to apply the effect<br />
&nbsp;*/</span><br />
override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">apply</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">target</span> : DisplayObject<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; ...<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>Special tags starting with an <span class="pre">@</span> can be used in these comments and will be interpreted by the ASDoc process. Fortunately HTML tags can be used as well inside these comments and will be output unchanged. I make use of this feature to insert SWF files inside the documentation.</p>
<h3>Step 1 : adding the required JavaScript libraries to the ASDoc templates</h3>
<p><em>Note </em>: in the following section you have to download several components to make it works. <a href="http://sroucheray.org/blog/wp-content/uploads/2010/02/asdoc-inline-swf-templates.zip">I packaged all of them in a zip file</a>.</p>
<p>ASDoc templates are located in a Flex SDK sub-directory by default : <span class="pre">FLEX_SDK_DIR\asdoc\templates</span><br />
To keep unmodified the original templates you can copy this folder outside the Flex directory. In this case to make the ASDoc process being aware of this change use the command parameter <span class="pre">-templates-path &#8216;path/to/your/new/template_folder&#8217;</span><br />
<a href="http://livedocs.adobe.com/flex/3/html/help.html?content=asdoc_1.html">Full ASDoc documentation is located on Adobe Web site</a></p>
<p>In the template folder locate the file <span class="pre">asdoc-util.xsl</span> and in there search for those lines :</p>
<div class="codecolorer-container xml dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">language</span>=<span style="color: #ff0000;">&quot;javascript&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;src&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$baseRef&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>asdoc.js<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:attribute<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>insert the following lines just before the previous ones :</p>
<div class="codecolorer-container xml dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">language</span>=<span style="color: #ff0000;">&quot;javascript&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;src&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$baseRef&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jquery.min.js<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:attribute<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">language</span>=<span style="color: #ff0000;">&quot;javascript&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;src&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$baseRef&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swfobject.js<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:attribute<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">language</span>=<span style="color: #ff0000;">&quot;javascript&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:attribute</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;src&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$baseRef&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swf-loader.js<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:attribute<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>As you may guess we will use jQuery and SWFObject to achieve our goal. Download <a href="http://jquery.com/">jQuery</a> and <a href="http://code.google.com/p/swfobject/">SWFObject</a> and put the files in the templates directory (rename the files to match the previous lines). From the SWFObject download ZIP file, extracts the <span class="pre">expressInstall.swf</span> file in the templates directory as well.</p>
<p>The third file is made by myself and will help substitute special HTML tags in the documentation by SWF files. Save the following code in the file <span class="pre">templates/swf-loader.js</span></p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> idBase <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;swfLoader&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> idNum <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> width<span style="color: #339933;">,</span> height<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> params <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; quality<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;high&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; scale<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;noscale&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; allowscriptaccess<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;always&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; bgcolor<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;#FFFFFF&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> flashvars <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div[src]&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">,</span>idBase <span style="color: #339933;">+</span> idNum<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; width <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'width'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #3366CC;">&quot;100%&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; height <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'height'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #3366CC;">&quot;100%&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> flasvarsString <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;flashvars&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> flashvarsArray <span style="color: #339933;">=</span> flasvarsString.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&amp;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> flashvarsArray.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> flasvar <span style="color: #339933;">=</span> flashvarsArray<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flashvars<span style="color: #009900;">&#91;</span>flasvar<span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> flasvar<span style="color: #009900;">&#91;</span>1<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; swfobject.<span style="color: #660066;">embedSWF</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; idBase <span style="color: #339933;">+</span> idNum<span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width<span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height<span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;10.0.0&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;expressInstall.swf&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flashvars<span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params<span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; idNum<span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<h3>Step 2 : adding special HTML Tag in  ASDoc classes comments</h3>
<p>Now that the files are in place it&#8217;s possible to add special HTML tags in comments to insert SWF files :</p>
<div class="codecolorer-container actionscript dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">/**<br />
&nbsp;* Creates an RGB distortion effect (Timed effect).<br />
&nbsp;* &lt;div src='../../../swf/effectTester.swf' <br />
&nbsp;* &nbsp; width='780px' height='550px' flashvars='form:mosaicForm'&gt;&lt;/div&gt;<br />
&nbsp;*/</span></div></div>
<p>The div tag will be replaced by the SWF files located at <span class="pre">&#8216;../../../swf/effectTester.swf&#8217;</span> passing <span class="pre">width</span>, <span class="pre">height</span> and <span class="pre">flashvars</span> parameters.<br />
Flashvars must be of the following form :<br />
<span class="pre">var1:value1&#038;var2:value2&#038;var3:value3</span>.</p>
<h3>Step 3 : where to put the SWF files</h3>
<p>Put the SWF files in the <span class="pre">doc_output_directory/swf</span>.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fsroucheray.org%2Fblog%2F2010%2F02%2Fhow-to-insert-a-swf-file-in-an-asdoc-api-documentation%2F&amp;linkname=How%20to%20insert%20a%20SWF%20file%20in%20an%20ASDoc%20API%20documentation%20%3F"><img src="http://sroucheray.org/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://sroucheray.org/blog/2010/02/how-to-insert-a-swf-file-in-an-asdoc-api-documentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Papervision : Mouse interaction with 2D MovieMaterial</title>
		<link>http://sroucheray.org/blog/2009/12/papervision-mouse-interaction-with-2d-moviematerial/</link>
		<comments>http://sroucheray.org/blog/2009/12/papervision-mouse-interaction-with-2d-moviematerial/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 13:01:55 +0000</pubDate>
		<dc:creator>Stéphane Roucheray</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Papervision]]></category>
		<category><![CDATA[MovieMaterial]]></category>
		<category><![CDATA[Papervision3D]]></category>

		<guid isPermaLink="false">http://sroucheray.org/blog/?p=508</guid>
		<description><![CDATA[The nature of Papervision MovieMaterial gives users the ability to interact with it's content. However it can be tricky to make it work.]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.papervision3d.org/">Papervision</a> lets apply textures as MovieClip on 3D object surfaces. This kind of textures is called <a href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/materials/MovieMaterial.html">MovieMaterial</a>. The nature of MovieMaterial gives users the ability to interact with it&#8217;s content. However it&#8217;s often tricky to make it works.</p>
<p>In the following example I applied a MovieMaterial to a <a href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/objects/primitives/Cube.html">Cube</a> (wihout depth so it looks like a <a href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/index.html?org/papervision3d/objects/primitives/Cube.html&#038;org/papervision3d/objects/primitives/class-list.html">PaperPlane</a>) :</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="600" height="600">
      <param name="movie" value="http://sroucheray.org/blog/wp-content/uploads/2009/11/moviematerial-interaction.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://sroucheray.org/blog/wp-content/uploads/2009/11/moviematerial-interaction.swf" width="600" height="600">
      <!--<![endif]-->
        <p>The Flash plugin is required to view this object.</p>
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p>The button and TextField are both children of the MovieClip used as the material in the MovieMaterial. This example shows how the mouse can interact with the button. While it rotates along with the cube and its MovieMaterial, it handles well the three events : mouse over, mouse out and mouse click.</p>
<h2>MouseClick on a button inside a MovieMaterial</h2>
<p>MouseClick on a button is really easy to implement. A simple listener is added to the button Object :</p>
<div class="codecolorer-container actionscript dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">//WhitePanel class is an asset in the Fla's library</span><br />
panel = <span style="color: #000000; font-weight: bold;">new</span> WhitePanel<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #808080; font-style: italic;">//Set up the okButton inside the panel</span><br />
<span style="color: #000000; font-weight: bold;">var</span> okButton : <span style="color: #0066CC;">MovieClip</span> = <span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#40;</span>panel.<span style="color: #006600;">okButton</span><span style="color: #66cc66;">&#41;</span>;<br />
okButton.<span style="color: #006600;">mouseChildren</span> = <span style="color: #000000; font-weight: bold;">false</span>;<br />
okButton.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, clickListener<span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #000000; font-weight: bold;">var</span> okInc : <span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">0</span>;<br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> clickListener <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp;++okInc;<br />
&nbsp;<span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span>panel.<span style="color: #006600;">title</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;Click on OK Button : &quot;</span>+ okInc;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>On button click the text field is well updated.</p>
<h2>Mouse over and mouse out a sprite inside a MovieMaterial</h2>
<p>The mouse over and mouse out events are a little bit more tricky to implement. In general, when a zone is interactive you want the mouse to change its aspects. When over it is transformed to a hand cursor and when out to the simple arrow cursor.<br />
When working on a 2D stage it is done via these affectations :</p>
<div class="codecolorer-container actionscript dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">okButton.<span style="color: #006600;">buttonMode</span> = <span style="color: #000000; font-weight: bold;">true</span>;<br />
okButton.<span style="color: #0066CC;">useHandCursor</span>= <span style="color: #000000; font-weight: bold;">true</span>; <span style="color: #808080; font-style: italic;">//This is true by default</span></div></div>
<p>Thus the hand cursor appears when over the okButton MovieClip. Unfortunately it doesn&#8217;t work with Papervision. The workaround is to affect handlers to the MovieClip and globally change the aspect of the mouse cursor :</p>
<div class="codecolorer-container actionscript dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">okButton.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_OVER</span>, handleOver<span style="color: #66cc66;">&#41;</span>;<br />
okButton.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_OUT</span>, handleOut<span style="color: #66cc66;">&#41;</span>;<br />
<br />
<span style="color: #000000; font-weight: bold;">function</span> handleOver<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//Globally change the mouse cursor aspect</span><br />
&nbsp; &nbsp; viewport.<span style="color: #006600;">containerSprite</span>.<span style="color: #006600;">buttonMode</span> = <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//Not required, changes the aspect of the button</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//in our case</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">currentTarget</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">gotoAndStop</span><span style="color: #66cc66;">&#40;</span>2<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #000000; font-weight: bold;">function</span> handleOut<span style="color: #66cc66;">&#40;</span>event:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//Globally change the mouse cursor aspect</span><br />
&nbsp; &nbsp; viewport.<span style="color: #006600;">containerSprite</span>.<span style="color: #006600;">buttonMode</span> = <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">MovieClip</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">currentTarget</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">gotoAndStop</span><span style="color: #66cc66;">&#40;</span>1<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>&#8212;</p>
<p>Download the demo sources <a href="http://sroucheray.org/blog/wp-content/plugins/download-monitor/download.php?id=1" title="Download MMInteractionDemo.zip">MMInteractionDemo.zip</a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fsroucheray.org%2Fblog%2F2009%2F12%2Fpapervision-mouse-interaction-with-2d-moviematerial%2F&amp;linkname=Papervision%20%3A%20Mouse%20interaction%20with%202D%20MovieMaterial"><img src="http://sroucheray.org/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://sroucheray.org/blog/2009/12/papervision-mouse-interaction-with-2d-moviematerial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Array.sort() should not be used to shuffle an array</title>
		<link>http://sroucheray.org/blog/2009/11/array-sort-should-not-be-used-to-shuffle-an-array/</link>
		<comments>http://sroucheray.org/blog/2009/11/array-sort-should-not-be-used-to-shuffle-an-array/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 12:48:43 +0000</pubDate>
		<dc:creator>Stéphane Roucheray</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[Randomize]]></category>
		<category><![CDATA[Sort]]></category>

		<guid isPermaLink="false">http://sroucheray.org/blog/?p=375</guid>
		<description><![CDATA[When a developer searches the web for an algorithm to shuffle an array in JavaScript or ActionScript, he will surely find a way to achieve that using the <samp>Array.sort()</samp> method (see references : <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/sort">JavaScript</a>, <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/Array.html#sort%28%29">ActionScript 3</a>)...]]></description>
			<content:encoded><![CDATA[<p>When a developer searches the web for an algorithm to shuffle an array in JavaScript or ActionScript, he will surely find a way to achieve that using the <samp>Array.sort()</samp> method (see references : <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/sort">JavaScript</a>, <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/Array.html#sort%28%29">ActionScript 3</a>). While this method is intended to sort an array, it can also be used to randomize it (!). In general, here and there, the following algorithm comes forth :</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">/**<br />
&nbsp;* Add a randomize method to the Array object prototype<br />
&nbsp;* Usage : <br />
&nbsp;* &nbsp;var tmpArray = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;];<br />
&nbsp;* &nbsp;tmpArray.randomize();<br />
&nbsp;*/</span><br />
Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">randomize</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">sort</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> Math.<span style="color: #660066;">round</span><span style="color: #009900;">&#40;</span> Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> 2 <span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></div>
<p>The principle of this implementation is simple. It takes advantage of the comparison <samp>Function</samp> that can be passed to the <samp>Array.sort()</samp> method. This function defines the sort order. It will be passed two objects (from the array) <samp>a</samp> and <samp>b</samp>, compare them and return <samp>-1</samp>, <samp>0</samp> or <samp>1</samp> whether <samp>a</samp> is less, equal or greater than <samp>b</samp>. The idea, to shuffle an array, is to randomly output <samp>-1</samp>, <samp>0</samp> or <samp>1</samp>. This is the purpose of the expression <samp>Math.round( Math.random() * 2 ) &#8211; 1</samp>. This idea is bad.</p>
<h2>Shuffling an array with <samp>Array.sort()</samp> results in&#8230; a not so shuffled array</h2>
<p>Implementing a shuffle function on arrays, this way, is bad. At first glance it seems to produce well randomized arrays, but the random distribution is not uniform. I will illustrate this in a minute. Before that, give a look at the table below. It&#8217;s interactive. When you click start, it will run the following process :</p>
<ol>
<li>
	Create an array with ten letters in alphabetical orders from A to J</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> simpleArray <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;A&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;B&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;C&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;D&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;E&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;F&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;G&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;H&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;I&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;J&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></div></div>
</li>
<li>Copy this array in a second array</li>
<li>Run a shuffle algorithm against the second array</li>
<li>Look where the letters are in the second array and record their position in the table columns</li>
<li>Return to the step 2 and start the process again until a certain number of iterations has been reached</li>
</ol>
<p>This repetitive process is pretty simple. It is not intended to give a mathematical evidence of the problem but to illustrate the consequences of a badly implemented shuffle algorithm. Note that the copy at step 2 is always made from the original array (not from the last shuffled array). </p>
<p>In this first example and to make sure you understand how this table work, step 3 is bypassed. Thus the copied array is always exactly the same as the original one. Click on <em>Start</em> button will launch the process (The number of iterations can be changed).</p>
<div id="noshuffle"></div>
<p>Normally, at the end of the process, you should see a table full of zeros with only the diagonal (top-left / bottom-right) filled with the number of iterations. It means that, at every steps, letters in the second array are at the same position than in the first one. This is what was expected because there is no shuffle.</p>
<p>Let&#8217;s do the same thing but now step 3 uses the shuffle algorithm we have seen before.</p>
<div id="arraysort"></div>
<p>The result is interesting, isn&#8217;t it ? The position of letters has well been set randomly over iterations. Almost every cells in the table are filled with numbers. Let&#8217;s give a closer look. Actually, the nearer a cell is from the diagonal (top-left / bottom-right) the higher its number. Moreover there are still zeros in some cells far from this diagonal. Obviously, it means letters are more likely to be near their original position, after a shuffle.</p>
<h2>How to better shuffle an array with <samp>Array.sort()</samp> ?</h2>
<p>We said the comparison function returned randomly either <samp>-1</samp>, <samp>0</samp> or <samp>1</samp>. What exactly happens in each case ? Let&#8217;s quote the Mozilla developer Center for the <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/sort#Description"><samp>Array.sort()</samp> comparison function description</a></p>
<div style="padding:1em 4em; font-size:1.1em;">
If <samp>compareFunction</samp> is supplied, the array elements are sorted according to the return value of the compare function. If a and b are two elements being compared, then:</p>
<ul>
<li>If <samp>compareFunction(a, b)</samp> is less than 0, sort <samp>a</samp> to a lower index than <samp>b</samp>.</li>
<li>If <samp>compareFunction(a, b)</samp> returns 0, leave <samp>a</samp> and <samp>b</samp> unchanged with respect to each other, but sorted with respect to all different elements. Note: the ECMAscript standard does not guarantee this behaviour, and thus not all browsers (e.g. Mozilla versions dating back to at least 2003) respect this.</li>
<li>If <samp>compareFunction(a, b)</samp> is greater than 0, sort <samp>b</samp> to a lower index than <samp>a</samp>.</li>
</ul>
</div>
<p>The <samp>Array.sort()</samp> method uses a <a href="http://en.wikipedia.org/wiki/Bubble_sort">Bubble Sort algorithm</a>. Roughly, it steps through array elements and compare each one with its next adjacent element. It swaps the elements when the comparison function return <samp>1</samp>. What does it do when the comparison function return <samp>0</samp> or <samp>-1</samp> ? Actually nothing and here is the issue ! As the comparison function randomly generate <samp>-1</samp>, <samp>0</samp> or <samp>1</samp>, each of those numbers has the same chance to arise. Unfortunately a letter can change its position only if <samp>1</samp> arises. It means that a letter has twice the chance not to move than to move !</p>
<p>So to resolve the issue the comparison function must not generate 3 numbers randomly but only two : <samp>0</samp> or <samp>1</samp>. Thus a letter has the same chance to move than to stay in place. Below is the new implementation (Note that it is simpler than the previous one).</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">/**<br />
&nbsp;* Add a randomize method to the Array object prototype<br />
&nbsp;* Usage : <br />
&nbsp;* &nbsp;var tmpArray = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;];<br />
&nbsp;* &nbsp;tmpArray.randomize2();<br />
&nbsp;*/</span><br />
Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">randomize2</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">sort</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> &nbsp;Math.<span style="color: #660066;">round</span><span style="color: #009900;">&#40;</span> Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></div>
<p>The following table shows the result of this new implementation :</p>
<div id="arraysort2"></div>
<p>This result seems much more random than the previous one. There are much less zeros filling the table, however we can still see a kind of diagonal pattern where higher numbers seem much more on the diagonal. It is less obvious than before but still there. The reason for this can be found in the Bubble Sort algorithm and its implementation. Think about if A &lt; B and B &lt; C then not need to compare A and C.Thus, some comparisons are not done and optimization in code results in a greater efficiency to sort but an issue when shuffle.</p>
<p><em>Update : it seems there are differences between browsers. Notably, the method explained here is more accurate in Firefox but less in IE. Both gives bad uniform random, though. Not tested in other browsers</em></p>
<h2>Shuffle arrays the good way</h2>
<p>Fortunately it is not required to use <samp>Array.sort()</samp> to shuffle an array. Implement a shuffle function using <a href="http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates algorithm</a> is better and still easy.</p>
<p>Below is the code implementing a shuffle function using the Fisher-Yates algorithm. This algorithm provides uniform random.</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">/*<br />
&nbsp;* Add a shuffle function to Array object prototype<br />
&nbsp;* Usage : <br />
&nbsp;* &nbsp;var tmpArray = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;];<br />
&nbsp;* &nbsp;tmpArray.shuffle();<br />
&nbsp;*/</span><br />
Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">shuffle</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">length</span><span style="color: #339933;">,</span> j<span style="color: #339933;">,</span> temp<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> i <span style="color: #339933;">==</span> 0 <span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">--</span>i <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; j <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span> Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span> i <span style="color: #339933;">+</span> 1 <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; temp <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> temp<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></div>
<p>To prove the superiority of Fisher-Yates algorithm in <samp>Array.sort()</samp> implementation play with the table below.</p>
<div id="shuffle"></div>
<p>With these results, it is obvious that this algorithm is far more efficient in distributing uniformly the letters in the array over iterations than <samp>Array.sort()</samp> style algorithms. Distribution is much more the same across cells.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fsroucheray.org%2Fblog%2F2009%2F11%2Farray-sort-should-not-be-used-to-shuffle-an-array%2F&amp;linkname=Array.sort%28%29%20should%20not%20be%20used%20to%20shuffle%20an%20array"><img src="http://sroucheray.org/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://sroucheray.org/blog/2009/11/array-sort-should-not-be-used-to-shuffle-an-array/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How to get a mouse hand over a TextField in AS3 ?</title>
		<link>http://sroucheray.org/blog/2009/11/how-to-get-a-mouse-hand-over-a-textfield-in-as3/</link>
		<comments>http://sroucheray.org/blog/2009/11/how-to-get-a-mouse-hand-over-a-textfield-in-as3/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 09:16:49 +0000</pubDate>
		<dc:creator>Stéphane Roucheray</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Hand]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mouse]]></category>
		<category><![CDATA[MouseOver]]></category>

		<guid isPermaLink="false">http://sroucheray.org/blog/?p=363</guid>
		<description><![CDATA[It's pretty simple...]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s pretty simple, <tt>buttonMode</tt> and <tt>mouseChildren</tt> properties of the <tt><a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/text/TextField.html">TextField</a></tt> parent should be set like that :</p>
<div class="codecolorer-container actionscript dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">var</span> sprite : Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">textField</span> : <span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
sprite.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">textField</span><span style="color: #66cc66;">&#41;</span>;<br />
<br />
sprite.<span style="color: #006600;">buttonMode</span> = <span style="color: #000000; font-weight: bold;">true</span>;<br />
sprite.<span style="color: #006600;">mouseChildren</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div></div>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fsroucheray.org%2Fblog%2F2009%2F11%2Fhow-to-get-a-mouse-hand-over-a-textfield-in-as3%2F&amp;linkname=How%20to%20get%20a%20mouse%20hand%20over%20a%20TextField%20in%20AS3%20%3F"><img src="http://sroucheray.org/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://sroucheray.org/blog/2009/11/how-to-get-a-mouse-hand-over-a-textfield-in-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML 5 support workarounds and fallbacks</title>
		<link>http://sroucheray.org/blog/2009/10/html5-support-workarounds-and-fallbacks/</link>
		<comments>http://sroucheray.org/blog/2009/10/html5-support-workarounds-and-fallbacks/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 12:58:42 +0000</pubDate>
		<dc:creator>Stéphane Roucheray</dc:creator>
				<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://sroucheray.org/blog/?p=305</guid>
		<description><![CDATA[HTML 5 is a kind of revolution in Web development nowadays, but is not well supported still. I put together here a list of workarounds and fallbacks you can use to start coding HTML5 while keeping a good cross browsers support. If you have suggestions just drop a comment !]]></description>
			<content:encoded><![CDATA[<p><em>Last update Thursday, October 8, 2009</em></p>
<p>HTML 5 is a kind of revolution in Web development nowadays, but is not well supported still. I put together here a list of workarounds and fallbacks you can use to start coding HTML5 while keeping a good cross browsers support. If you have suggestions just drop a comment !</p>
<ul>
<li><a href="#html5-tags">HTML5 tags and IE</a></li>
<li><a href="#audio">Audio</a></li>
<li><a href="#canvas">Canvas</a></li>
<li><a href="#svg">SVG</a></li>
<li><a href="#video">Video</a></li>
<li><a href="#web-forms">Web forms 2.0</a></li>
<li><a href="#web-workers">Web Workers</a></li>
</ul>
<h2 id="html5-tags">HTML5 tags and IE</h2>
<p>IE will fail to style tags it does not recognize, especially the new HTML5 semantic tags like <tt>section</tt>, <tt>article</tt>, <tt>aside</tt>&#8230; The workaround is to help it identify those tags by using this small piece of JavaScript :</p>
<div class="codecolorer-container javascript dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;section&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Several JavaScript libraries help to detect  <a href="http://www.modernizr.com/">http://www.modernizr.com/</a> or even to fix <a href="http://code.google.com/p/html5shiv/">http://code.google.com/p/html5shiv/</a> HTML5 support in IE.</p>
<p>Source : <a href="http://blog.whatwg.org/supporting-new-elements-in-ie">http://blog.whatwg.org/supporting-new-elements-in-ie</a></p>
<h2 id="audio">Audio</h2>
<p>A JavaScript exists which tests the <tt>audio</tt> element and the <tt>Audio()</tt> object support :<br />
<a href="http://www.happyworm.com/jquery/jplayer/HTML5.Audio.Support/">http://www.happyworm.com/jquery/jplayer/HTML5.Audio.Support/</a></p>
<h2 id="canvas">Canvas</h2>
<p>A JavaScript library exists to simulate <tt>canvas</tt> tag in Internet Explorer : <a href="http://code.google.com/p/explorercanvas/">http://code.google.com/p/explorercanvas/</a> </p>
<h2 id="svg">SVG</h2>
<p>Google has developped a JavaScript library to simulate SVG in browser that does not support it <a href="http://code.google.com/p/svgweb/">http://code.google.com/p/svgweb/</a></p>
<h2 id="video">Video</h2>
<p>There are several support levels of the HTML 5 <tt>video</tt> tag. Internet Explorer does not support it at all. Firefox, Safari and Chrome, in there last release, support it but with different codecs. As a result the best way to use the video tag is : first, by providing sources with different codecs, second by providing a Flash fallback :</p>
<div class="codecolorer-container html4strict dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;video controls&gt;</span><br />
<span style="color: #009900;">&lt;source <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;zombie.ogg&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;video/ogg&quot;</span><span style="color: #66cc66;">/</span>&gt;</span><br />
<span style="color: #009900;">&lt;source <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;zombie.mp4&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;video/mp4&quot;</span><span style="color: #66cc66;">/</span>&gt;</span><br />
<span style="color: #009900;">&lt;embed <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://blip.tv/play/AYGLzBmU8hw&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;application/x-shockwave-flash&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;500&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;396&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;allowscriptaccess<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;always&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;allowfullscreen<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #66cc66;">/</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>video&gt;</span></div></div>
<p>This fallback should be supported by all the major browsers. If you require more support for iPhone, Quicktime&#8230; you should give a look at other solutions like : <a href="http://camendesign.com/code/video_for_everybody">Video for everybody</a></p>
<p>Sources :<br />
<a href="http://hacks.mozilla.org/2009/06/html5-video-fallbacks-markup/">http://hacks.mozilla.org/2009/06/html5-video-fallbacks-markup/</a><br />
<a href="https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox">https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox</a></p>
<h2 id="web-forms">Web Forms 2.0</h2>
<p>A JavaScript library exists to emulate Web Forms 2.0 : <a href="http://code.google.com/p/webforms2/">http://code.google.com/p/webforms2/</a>.<br />
More information on Web Forms 2.0 emulation can be found here : <a href="http://wiki.whatwg.org/wiki/Implementations_in_Web_browsers">http://wiki.whatwg.org/wiki/Implementations_in_Web_browsers</a></p>
<h2 id="web-workers">Web workers</h2>
<p>The ability to do JavaScript threading is partially emulated by a JavaScript library : <a href="http://code.google.com/p/fakeworker-js/">http://code.google.com/p/fakeworker-js/</a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fsroucheray.org%2Fblog%2F2009%2F10%2Fhtml5-support-workarounds-and-fallbacks%2F&amp;linkname=HTML%205%20support%20workarounds%20and%20fallbacks"><img src="http://sroucheray.org/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://sroucheray.org/blog/2009/10/html5-support-workarounds-and-fallbacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Toolbox</title>
		<link>http://sroucheray.org/blog/2009/09/flash-toolbox/</link>
		<comments>http://sroucheray.org/blog/2009/09/flash-toolbox/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 10:35:58 +0000</pubDate>
		<dc:creator>Stéphane Roucheray</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://sroucheray.org/blog/?p=272</guid>
		<description><![CDATA[I maintain here some ActionScript3 tools and frameworks I use in my day to day work.]]></description>
			<content:encoded><![CDATA[<p><em>Last update Wednesday, December 2, 2009</em></p>
<p>I maintain here some ActionScript3 tools and frameworks I use in my day to day work. This list is not intended to reflect all tools you can Google out there, just the ones I use. If you know something I should test and add here, <a href="http://sroucheray.org/blog/contact/">send me an email</a>.</p>
<h2 id="editors">Editors</h2>
<ul>
<li> <strong>FDT</strong> : <a href="http://fdt.powerflasher.com/">http://fdt.powerflasher.com/</a>
<p>The best ActionScript editor I have used so far. Based on Eclipse : syntax and error highlighting, completion, debugger&#8230;</p>
<p><em>Alternatives : <a href="http://www.flashdevelop.org/wikidocs/index.php?title=Main_Page">Flash Develop</a> | <a href="http://www.adobe.com/products/flex/">Flex Builder</a></em><br />
<em>Must have tool : <a href="http://www.rozengain.com/blog/2009/10/09/eclipse-plug-in-download-as3-libraries-straight-to-your-eclipseflex-builderfdt-project/">eclipse-plug-in-download-as3-libraries-straight-to-your-eclipseflex-builderfdt-project</a> quite a long but expressive name, isn&#8217;t it ?</em></li>
<li> <strong>Notepad++</strong> : <a href="http://notepad-plus.sourceforge.net/">http://notepad-plus.sourceforge.net/</a>
<p>
Not specially dedicated to ActionScript but really handy to open all kind of files with colour highlighting (AS, XML, JS, HTML) and to make quick modifications or to do repetitive tasks (a lot of plugins included by default).
</p>
</li>
</ul>
<h2 id="frameworks">Frameworks</h2>
<ul>
<li>
<strong>AMFPHP</strong> : <a href="http://www.amfphp.org/">http://www.amfphp.org/</a></p>
<p>
Ease communication between ActionScript and PHP.
</p>
</li>
<li> <strong>AS3Dmod</strong> : <a href="http://code.google.com/p/as3dmod/">http://code.google.com/p/as3dmod/</a> | <a href="http://www.everydayflash.com/flash/as3dmod/doc/">API</a>
<p>3D modifiers for Papervision 3D. Intended to change 3D objects aspect applying constraints on them.
</li>
<li> <strong>Papervision3D</strong> : <a href="http://dev.papervision3d.org/">http://dev.papervision3d.org/</a> | <a href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/index.html">API</a>
<p>Realtime 3D engine.</p>
<p><em>Alternatives : <a href="http://away3d.com/">Away 3D</a>,  <a href="http://www.flashsandy.org/">Sandy</a></em><br />
<em>Must have tools : <a href="http://www.rozengain.com/blog/2008/01/02/export-your-blender-objects-straight-to-away3d-papervision3d-and-sandy/">Blender to AS3 export</a>, <a href="http://blog.anthony-scavarelli.com/?p=77">Air Collada Viewer</a>, <a href="http://www.closier.nl/prefab/">Air Prefab : Away3D texture mapping</a></em></li>
<li> <strong>Gaia Flash Framework</strong> : <a href="http://www.gaiaflashframework.com/">http://www.gaiaflashframework.com/</a>
<p>A flash site or module manager. It handles pages, transitions, depth, assets&#8230; A great tool for developers when they work with artists.</p>
</li>
<li> <strong>Tweenlite / Tweenmax</strong> : <a href="http://blog.greensock.com/tweenliteas3/">http://blog.greensock.com/tweenliteas3/</a>
<p>Great tweening engine : help to manage transitions incrementing or decrementing any number values of any object during a specified amount of time. It offers several transitions curves.<br />
<em><br />
Alternatives : <a href="http://code.google.com/p/tweener/">Tweener</a> | <a href="http://gskinner.com/libraries/gtween/">gTween</a></em></li>
<li> <strong>Thunderbolt</strong> : <a href="http://code.google.com/p/flash-thunderbolt/">http://code.google.com/p/flash-thunderbolt/</a>
<p>Logging in FDT, Flash IDE and Firebug ! What else ?</p>
</li>
<li> <strong>Mr. Doob</strong> : <a href="http://code.google.com/p/mrdoob/">http://code.google.com/p/mrdoob/</a>
<p>Useful bunch of classes : <a href="http://code.google.com/p/mrdoob/wiki/stats">Stats</a>, <a href="http://code.google.com/p/mrdoob/wiki/videoplayer">Video player</a>
</p>
</li>
</ul>
<h2 id="javascript">JavaScript</h2>
<ul>
<li> <strong>SWFObject2</strong> : <a href="http://code.google.com/p/swfobject/">http://code.google.com/p/swfobject/</a>
<p>Safely embed SWF files in Web pages without struggling with browser detection and specific implementations.
</li>
<li> <strong>SWFFIT</strong> : <a href="http://swffit.millermedeiros.com/">http://swffit.millermedeiros.com/</a>
<p>
Smartly activate scrollbars to the browser if a SWF object is greater than the size of the browser window. Great for full Flash sites !
</p>
</li>
</ul>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fsroucheray.org%2Fblog%2F2009%2F09%2Fflash-toolbox%2F&amp;linkname=Flash%20Toolbox"><img src="http://sroucheray.org/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://sroucheray.org/blog/2009/09/flash-toolbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Twitter API plugin</title>
		<link>http://sroucheray.org/blog/2009/07/jquery-twitter-api-plugin/</link>
		<comments>http://sroucheray.org/blog/2009/07/jquery-twitter-api-plugin/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 13:02:04 +0000</pubDate>
		<dc:creator>Stéphane Roucheray</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://sroucheray.org/blog/?p=186</guid>
		<description><![CDATA[I have released a simple Twitter public API for jQuery. It's Open Source and available at Google Code.]]></description>
			<content:encoded><![CDATA[<p>I have released a simple Twitter public API for jQuery. Code and examples are open source and can be download here : <a href="http://code.google.com/p/jquery-twitter-api/">http://code.google.com/p/jquery-twitter-api/</a>.</p>
<p><em>NB : informations requiring authentication are not accessible to JavaScript inside classical Web pages because of the <a href="https://developer.mozilla.org/en/Same_origin_policy_for_JavaScript">same origin policy restriction</a>. Thus this plugin is only intended to access publicly available data.</em></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fsroucheray.org%2Fblog%2F2009%2F07%2Fjquery-twitter-api-plugin%2F&amp;linkname=jQuery%20Twitter%20API%20plugin"><img src="http://sroucheray.org/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://sroucheray.org/blog/2009/07/jquery-twitter-api-plugin/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Mozilla Hacks</title>
		<link>http://sroucheray.org/blog/2009/06/mozilla-hacks/</link>
		<comments>http://sroucheray.org/blog/2009/06/mozilla-hacks/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 20:34:29 +0000</pubDate>
		<dc:creator>Stéphane Roucheray</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[mozilla]]></category>

		<guid isPermaLink="false">http://sroucheray.org/blog/?p=73</guid>
		<description><![CDATA[<em>Content Aware Image Resizing</em>  as the first demo of Mozilla Hacks, a new web site to introduce Firefox 3.5 new features. ]]></description>
			<content:encoded><![CDATA[<div id="attachment_82" class="wp-caption aligncenter" style="width: 511px"><a href="http://hacks.mozilla.org"><img class="size-full wp-image-82" title="mozilla-hacks" src="http://sroucheray.org/blog/wp-content/uploads/2009/06/mozilla-hacks.png" alt="Mozilla Hacks" width="501" height="251" /></a><p class="wp-caption-text">Mozilla Hacks</p></div>
<p>Firefox 3.5 is going to be released in a few weeks. To highlight some of the new features, Mozilla launched a new website.</p>
<p><strong><a href="http://hacks.mozilla.org/">http://hacks.mozilla.org/</a></strong></p>
<p>Mozilla Hacks presents articles and demos, either from core Mozilla hackers or from Web Developer like me. I&#8217;m very proud that the Mozilla Team chose as first demo the one I made at Pims Labs &#8220;<a href="http://labs.pimsworld.org/wp-content/uploads/2009/04/demo-content-aware-image-resizing-2/">Content Aware Image Resizing implemented with JavaScript</a>&#8220;.</p>
<p>The post is here <strong><a href="http://hacks.mozilla.org/2009/06/content-aware-image-resizing/">http://hacks.mozilla.org/2009/06/content-aware-image-resizing/</a></strong></p>
<p>I would like to thanks all Mozilla team for that !</p>
<p><strong>Update : two Chinese translations have been posted here <a href="http://www.mijia.org/blog/?p=196">(zh-CN) 内容感知的图片大小调整 </a> and here <a href="http://blog.bobchao.net/2009/06/35-1-canvas.html">(zh-TW) 內容感知式圖片縮小法。</a></strong></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fsroucheray.org%2Fblog%2F2009%2F06%2Fmozilla-hacks%2F&amp;linkname=Mozilla%20Hacks"><img src="http://sroucheray.org/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://sroucheray.org/blog/2009/06/mozilla-hacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 : le futur de la vidéo et du son sur internet</title>
		<link>http://sroucheray.org/blog/2009/06/html5-le-futur-de-la-video-et-du-son-sur-internet/</link>
		<comments>http://sroucheray.org/blog/2009/06/html5-le-futur-de-la-video-et-du-son-sur-internet/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 19:51:38 +0000</pubDate>
		<dc:creator>Stéphane Roucheray</dc:creator>
				<category><![CDATA[Pims World]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://sroucheray.org/blog/2009/06/html5-le-futur-de-la-video-et-du-son-sur-internet/</guid>
		<description><![CDATA[Video tag by Dailymotion on Pims World Labs (French)...]]></description>
			<content:encoded><![CDATA[<p><a href="http://labs.pimsworld.org/2009/05/html5-futur-de-la-video-et-du-son-sur-internet/" target="_self">http://labs.pimsworld.org/2009/05/html5-futur-de-la-video-et-du-son-sur-internet/</a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fsroucheray.org%2Fblog%2F2009%2F06%2Fhtml5-le-futur-de-la-video-et-du-son-sur-internet%2F&amp;linkname=HTML5%20%3A%20le%20futur%20de%20la%20vid%C3%A9o%20et%20du%20son%20sur%20internet"><img src="http://sroucheray.org/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://sroucheray.org/blog/2009/06/html5-le-futur-de-la-video-et-du-son-sur-internet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A JavaScript implementation of the Content Aware Image Resizing algorithm</title>
		<link>http://sroucheray.org/blog/2009/06/a-javascript-implementation-of-the-content-aware-image-resizing-algorithm/</link>
		<comments>http://sroucheray.org/blog/2009/06/a-javascript-implementation-of-the-content-aware-image-resizing-algorithm/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 19:51:38 +0000</pubDate>
		<dc:creator>Stéphane Roucheray</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Pims World]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[canvas]]></category>

		<guid isPermaLink="false">http://sroucheray.org/blog/2009/06/a-javascript-implementation-of-the-content-aware-image-resizing-algorithm/</guid>
		<description><![CDATA[The famous algorithm implemented with JavaScript on Pims World Labs...]]></description>
			<content:encoded><![CDATA[<p><a href="http://labs.pimsworld.org/2009/05/a-javascript-implementation-of-the-content-aware-image-resizing-algorithm/" target="_self">http://labs.pimsworld.org/2009/05/a-javascript-implementation-of-the-content-aware-image-resizing-algorithm/</a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fsroucheray.org%2Fblog%2F2009%2F06%2Fa-javascript-implementation-of-the-content-aware-image-resizing-algorithm%2F&amp;linkname=A%20JavaScript%20implementation%20of%20the%20Content%20Aware%20Image%20Resizing%20algorithm"><img src="http://sroucheray.org/blog/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://sroucheray.org/blog/2009/06/a-javascript-implementation-of-the-content-aware-image-resizing-algorithm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
