<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:series="http://unfoldingneurons.com/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Activetuts+</title>
	
	<link>http://active.tutsplus.com</link>
	<description>Browser app and game development tutorials, from beginner to advanced</description>
	<lastBuildDate>Sun, 12 Feb 2012 09:12:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Flashtuts" /><feedburner:info uri="flashtuts" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><image><link>http://active.tutsplus.com</link><url>http://envato.s3.amazonaws.com/rss_images/activetuts.jpg</url><title>Activetuts+</title></image><feedburner:emailServiceId>Flashtuts</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Build an HTML5 MP3 Player With SoundManager 2 – Tuts+ Premium</title>
		<link>http://feedproxy.google.com/~r/Flashtuts/~3/uETcVUZF0Dc/</link>
		<comments>http://active.tutsplus.com/tutorials/media/build-an-html5-mp3-player-with-soundmanager-2-tuts-premium/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 07:00:45 +0000</pubDate>
		<dc:creator>James Tyner</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Media]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[mp3 player]]></category>
		<category><![CDATA[Premium]]></category>
		<category><![CDATA[sound]]></category>
		<category><![CDATA[soundmanager 2]]></category>
		<guid isPermaLink="false">http://active.tutsplus.com/?p=10841</guid>
		<description>&lt;p&gt;It&amp;#8217;s time for another Premium tutorial! This week, James Tyner will walk you through the process of building an HTML5 MP3 player, step by step, with the SoundManager 2 library, jQuery, and a little help from Flash (for extra audio functionality).&lt;/p&gt;
&lt;p&gt;&lt;span id="more-10841"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Premium Preview&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;&lt;a href="http://d2fhka9tf2vaj2.cloudfront.net/premium/061_mp3Player/demo/index.html"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/premium/061_mp3Player/HTML5_MP3_Player.png" alt="SoundManager 2 HTML5 MP3 Player tutorial" /&gt;&lt;/a&gt;&lt;br /&gt;Click for a demo.&lt;/div&gt;
&lt;blockquote&gt;&lt;p&gt;In this tutorial I will show you how to create a JavaScript MP3 Player with jQuery and the &lt;a href="http://www.schillmania.com/projects/soundmanager2/doc/download/" rel="external"&gt;SoundManager 2&lt;/a&gt; JavaScript library that uses a hidden SWF file to play the sounds. (I could have used HTML5 Audio, but we would have lost the ID3 functionality, and so would have had to hard-code all of our artists and titles.)&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;You&amp;#8217;ll use jQuery, jQuery UI, and jScroller to manage the UI, with graphics already provided for you, and learn how to use SoundManager 2, a cross-browser JavaScript audio library that even works on iOS (if you are willing to lose the extra features, such as ID3 functionality).&lt;/p&gt;
&lt;p&gt;Everything is explained step by step as you build the player. &lt;a href="http://d2fhka9tf2vaj2.cloudfront.net/premium/061_mp3Player/demo/index.html"&gt;Check out the demo&lt;/a&gt; to see the end result.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Read the Full Tutorial&lt;/h2&gt;
&lt;p&gt;Premium members can &lt;a href="http://tutsplus.com/tutorial/build-an-html5-mp3-player-with-soundmanager-2-and-a-little-help-from-flash/"&gt;access the full tutorial right away&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;If you&amp;#8217;re not yet a Premium member, you can still &lt;a href="http://tutsplus.com/tutorial/build-an-html5-mp3-player-with-soundmanager-2-and-a-little-help-from-flash/"&gt;read the first few steps of the tutorial, which are enough to help you code the basic play and stop buttons.&lt;/a&gt;. &lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Tuts+ Premium Membership&lt;/h2&gt;
&lt;p&gt;We run a Premium membership system which periodically gives members access to extra tutorials, like this one! You&amp;#8217;ll also get access to Psd Premium, Vector Premium, Audio Premium, Net Premium, Ae Premium, Cg Premium, Photo Premium, and the new Mobile Premium too. If you&amp;#8217;re a Premium member, you can &lt;a href="http://tutsplus.com/"&gt;log in and download the tutorial&lt;/a&gt;. If you&amp;#8217;re not a member, you can of course &lt;a href="http://tutsplus.com/join/"&gt;join today&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;Also, don&amp;#8217;t forget to follow &lt;a href="http://twitter.com/envatoactive"&gt;@envatoactive on twitter&lt;/a&gt;,  &lt;a href="https://plus.google.com/116404059866243074508"&gt;circle us on Google+&lt;/a&gt;, &lt;a href="http://facebook.com/activetuts"&gt;like us on Facebook&lt;/a&gt;, and grab the &lt;a href="http://feedproxy.google.com/flashtuts"&gt;Activetuts+ RSS Feed&lt;/a&gt; to stay up to date with the latest tutorials and articles.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/zVON1LDDuXJum-lyegknNJfWhIo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zVON1LDDuXJum-lyegknNJfWhIo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/zVON1LDDuXJum-lyegknNJfWhIo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zVON1LDDuXJum-lyegknNJfWhIo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=uETcVUZF0Dc:1WGhA1V12tQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=uETcVUZF0Dc:1WGhA1V12tQ:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=uETcVUZF0Dc:1WGhA1V12tQ:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=uETcVUZF0Dc:1WGhA1V12tQ:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=uETcVUZF0Dc:1WGhA1V12tQ:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=uETcVUZF0Dc:1WGhA1V12tQ:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=uETcVUZF0Dc:1WGhA1V12tQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=uETcVUZF0Dc:1WGhA1V12tQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=uETcVUZF0Dc:1WGhA1V12tQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=uETcVUZF0Dc:1WGhA1V12tQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Flashtuts/~4/uETcVUZF0Dc" height="1" width="1"/&gt;</description>
		<wfw:commentRss>http://active.tutsplus.com/tutorials/media/build-an-html5-mp3-player-with-soundmanager-2-tuts-premium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://active.tutsplus.com/tutorials/media/build-an-html5-mp3-player-with-soundmanager-2-tuts-premium/</feedburner:origLink></item>
		<item>
		<title>Circular Motion in AS3: Make One Moving Object Orbit Another</title>
		<link>http://feedproxy.google.com/~r/Flashtuts/~3/dO7U4RtKB30/</link>
		<comments>http://active.tutsplus.com/tutorials/actionscript/circular-motion-in-as3-make-one-moving-object-orbit-another/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 06:00:28 +0000</pubDate>
		<dc:creator>Tyler Seitz</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[circular motion]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[orbit]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://active.tutsplus.com/?p=10833</guid>
		<description>&lt;p&gt;Having one object orbit another is a movement mechanic that&amp;#8217;s been used since the early gaming era, and it remains handy to this very day! In this Quick Tip we will explore the mathematical function for orbiting, see how to modify it, and look at practical uses in actual game design.&lt;span id="more-10833"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;Final Result Preview&lt;/h2&gt;
&lt;p&gt;Here&amp;#8217;s what we will be working towards:&lt;/p&gt;
&lt;div class="tutorial_image"&gt;
&lt;object width="350" height="350" data="http://d2fhka9tf2vaj2.cloudfront.net/tuts/407_qtOrbit/orbitingObjects.swf" type="application/x-shockwave-flash"&gt;&lt;param name="src" value="http://d2fhka9tf2vaj2.cloudfront.net/tuts/407_qtOrbit/orbitingObjects.swf" /&gt;&lt;/object&gt;
&lt;/div&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 1:&lt;/span&gt; The Orbiting Equation&lt;/h2&gt;
&lt;p&gt;To create an orbit we must define the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Origin &amp;#8211; The object or position that the orbit centers on.&lt;/li&gt;
&lt;li&gt;Orbiter &amp;#8211; The object that orbits the origin.&lt;/li&gt;
&lt;li&gt;Angle &amp;#8211; The current angle of the orbiter.&lt;/li&gt;
&lt;li&gt;Speed &amp;#8211; The number of pixels our object orbits per frame.&lt;/li&gt;
&lt;li&gt;Radius &amp;#8211; The orbiter&amp;#8217;s distance from the origin.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is also helpful to note that Flash&amp;#8217;s coordinate system is like &lt;a href="http://active.tutsplus.com/tutorials/games/quick-tip-trigonometry-for-flash-game-developers-basix/"&gt;a regular cartesian plane&lt;/a&gt;, except that the y-axis is flipped, so the value increases as we move downwards. The top-left corner of the stage has coordinates &lt;code&gt;(0,0)&lt;/code&gt;&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/407_qtOrbit/grid.png" alt="grid" /&gt;&lt;br /&gt;In this image, 0, 90, 180, and 270 refer to angles, measured in degrees.&lt;/div&gt;
&lt;p&gt;Another thing that we need to understand is how to convert degrees to radians, which can easily be accomplished using the following formula:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Radians = Degrees * (PI / 180)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Here&amp;#8217;s the actual orbiting function: it requires two lines, one to position the orbiter on the x-axis and the other to position it on the y-axis:&lt;/p&gt;
&lt;p&gt;Orbiter X-Coord = Origin X-Coord + Radius * cos(Radians)&lt;/p&gt;
&lt;p&gt;Orbiter Y-Coord = Origin Y-Coord + Radius * sin(Radians)&lt;/p&gt;
&lt;p&gt;(In a normal Cartesian plane, &lt;code&gt;sin&lt;/code&gt; is used for the x-coord and &lt;code&gt;cos&lt;/code&gt; is used for the y-coord, but since our angles are increasing clockwise &amp;#8211; due to the reversed y-axis &amp;#8211; their places are swapped.)&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 2:&lt;/span&gt; Writing the Equation in Code&lt;/h2&gt;
&lt;p&gt;We can now turn the logic into actual code that we can use. First, declare all of the variables:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
public var orbiter:Orbiter = new Orbiter(); // The MovieClip That Orbits
public var origin:Origin = new Origin(); // The MovieClip That Is Orbited
public var angle:Number = 0; // The Initial Angle Orbiting Starts From
public var speed:Number = 3; // Number Of Pixels Orbited Per Frame
public var radius:Number = 75; // Orbiting Distance From Origin
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Next rewrite the equation for use in AS3 and put it into an &lt;code&gt;ENTER_FRAME&lt;/code&gt; event handler function:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
var rad:Number = angle * (Math.PI / 180); // Converting Degrees To Radians
orbiter.x = origin.x + radius * Math.cos(rad); // Position The Orbiter Along x-axis
orbiter.y = origin.y + radius * Math.sin(rad); // Position The Orbiter Along y-axis
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;If you test now, nothing will happen; this is because the variable angle is neither increasing nor decreasing. Therefore, we must increase or decrease the value:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
angle += speed; // Object will orbit clockwise
angle -= speed; // Object will orbit counter-clockwise
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Now what if we want our orbiter to continuously face a direction? Well I have written an equation to do just that!&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
orbiter.rotation = (Math.atan2(orbiter.y-origin.y, orbiter.x-origin.x) * 180 / Math.PI);
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Depending on which way you have drawn your orbiter movieclip you may have to subtract a certain angle (outside the brackets) to get it to face the correct way.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 3:&lt;/span&gt; Transforming the Equation&lt;/h2&gt;
&lt;p&gt;Now this may sound crazy, but some of us might want to have our object orbit in an ellipse. This is easily doable; all we have to do is multiply in a specific place in the equation. Multiplying the &lt;code&gt;cos&lt;/code&gt; or &lt;code&gt;sin&lt;/code&gt; functions by a postive whole number will cause the circle to stretch. Multiplying it by a decimal between 0 &amp;#8211; 1 will cause it to compress. And multiplying it by a negative will cause it to flip along that axis:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
(2 * Math.cos(rad)); // Stretch the orbit along the x-axis by a factor of 2
(0.5 * Math.sin(rad)); // Compress the orbit along the y-axis by a factor of 2 (i.e. halve it)
(-3 * Math.cos(rad)); // Flip the orbit along the x-axis and stretch it by a factor of 3
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;We can also shift the orbit in any direction we want by adding or subtracting from the equation on either axis:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
orbiter.x = (origin.x + radius * Math.cos(rad))-50; // Shift the orbit 50 pixels left on the x-axis
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;If you want to learn more about &lt;code&gt;cos&lt;/code&gt;, &lt;code&gt;sin&lt;/code&gt;, and &lt;code&gt;atan2&lt;/code&gt;, take a look at &lt;a href="http://active.tutsplus.com/tutorials/games/quick-tip-trigonometry-for-flash-game-developers-basix/"&gt;Trigonometry for Flash Developers&lt;/a&gt;.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 4:&lt;/span&gt; Practical Uses for the Equation&lt;/h2&gt;
&lt;p&gt;Now this is all fine and dandy, but what can it actually be used for? A wide variety of things actually! &lt;/p&gt;
&lt;p&gt;If you have ever played Mario Kart you would have gotten the &amp;#8220;three shells&amp;#8221; powerup; those shells are orbiting using this very technique. Another example is the widely over-used circle pong game, where the paddle orbits along a ring on the outside. A third example is from top down zombie shooter games: a lot of them include a powerup where a grouping of barrels orbits around your player and crushes any zombies if they are hit trying to attack you. &lt;/p&gt;
&lt;p&gt;As you can see the use for this technique can be used in anything from industry standard games to casual games.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Thank you for taking the time to learn this Quick Tip! If you have any questions leave a comment below.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/e61jB1Uw-zTcTn83HbfvYVnjZr4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/e61jB1Uw-zTcTn83HbfvYVnjZr4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/e61jB1Uw-zTcTn83HbfvYVnjZr4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/e61jB1Uw-zTcTn83HbfvYVnjZr4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=dO7U4RtKB30:wu5pkyCwLd0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=dO7U4RtKB30:wu5pkyCwLd0:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=dO7U4RtKB30:wu5pkyCwLd0:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=dO7U4RtKB30:wu5pkyCwLd0:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=dO7U4RtKB30:wu5pkyCwLd0:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=dO7U4RtKB30:wu5pkyCwLd0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=dO7U4RtKB30:wu5pkyCwLd0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=dO7U4RtKB30:wu5pkyCwLd0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=dO7U4RtKB30:wu5pkyCwLd0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=dO7U4RtKB30:wu5pkyCwLd0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Flashtuts/~4/dO7U4RtKB30" height="1" width="1"/&gt;</description>
		<wfw:commentRss>http://active.tutsplus.com/tutorials/actionscript/circular-motion-in-as3-make-one-moving-object-orbit-another/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://active.tutsplus.com/tutorials/actionscript/circular-motion-in-as3-make-one-moving-object-orbit-another/</feedburner:origLink></item>
		<item>
		<title>Review: Construct 2, a Drag and Drop HTML5 Game Maker</title>
		<link>http://feedproxy.google.com/~r/Flashtuts/~3/Yh9C0OPPp7k/</link>
		<comments>http://active.tutsplus.com/articles/reviews/review-construct-2-a-drag-and-drop-html5-game-maker/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 13:00:29 +0000</pubDate>
		<dc:creator>Daniel Sidhion</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[construct 2]]></category>
		<category><![CDATA[gamedev]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[scirra]]></category>
		<guid isPermaLink="false">http://active.tutsplus.com/?p=10825</guid>
		<description>&lt;p&gt;Construct 2 is an HTML5 game making tool that doesn&amp;#8217;t require any programming knowledge. You just drag and drop items around, add behaviors to them, and make them come alive with &amp;#8220;events&amp;#8221;.&lt;/p&gt;
&lt;p&gt;In this review I will see what Construct 2 is capable of, from my perspective as a Flash game developer. Read the review to see whether or not this tool will serve the purpose of getting my games on more platforms!&lt;/p&gt;
&lt;p&gt;&lt;span id="more-10825"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;First Impressions&lt;/h2&gt;
&lt;p&gt;Downloading and installing &lt;a href="http://www.scirra.com/" rel="external"&gt;Construct 2&lt;/a&gt; was very easy. It comes as a single .exe installer for Windows (&lt;a href="http://www.scirra.com/construct2/faq#mac"&gt;no Mac version at the moment&lt;/a&gt;) and the installation steps are very simple.&lt;/p&gt;
&lt;p&gt;When you first open the app, it shows you a nice &amp;#8220;Hello!&amp;#8221; popup asking if you want to read the tutorials, browse examples or buy a license. I chose not to do any of the above, because I wanted to see how intuitive Construct 2 would be for me.&lt;/p&gt;
&lt;p&gt;If you ever want to read the &lt;a href="http://www.scirra.com/manual/1/construct-2" rel="external"&gt;manual&lt;/a&gt;, follow the &lt;a href="http://www.scirra.com/tutorials" rel="external"&gt;tutorials&lt;/a&gt; or browse the &lt;a href="http://www.scirra.com/forum/" rel="external"&gt;forums&lt;/a&gt;, Construct 2 always provides links in the start page or through the &amp;#8220;Home&amp;#8221; menu.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/articles/085_construct2review/InitialPopup.jpg" alt="Initial popup" /&gt;&lt;/div&gt;
&lt;p&gt;Construct 2 has an interface very similar to Microsoft&amp;#8217;s Office products. This makes it easy for people who are used to the Office products &amp;#8211; but not for me, a fan of the old drop-down menus.&lt;/p&gt;
&lt;p&gt;I started a new project by clicking the &amp;#8220;Create new project&amp;#8221; text in the start page, and after choosing whether I wanted to keep the project in a single file or in a folder, I was led straight to a blank screen, ready to work.&lt;/p&gt;
&lt;p&gt;At that stage I didn&amp;#8217;t know much about the tool, so I started by changing the Project Settings on the &amp;#8220;Properties&amp;#8221; tab on the left of the screen. After doing that, I started dragging a few images from my Windows folders to Construct 2, and it automatically recognized them and imported them into the project. Within minutes I managed to set up a very simple level for a platformer game, but at that moment the objects were only images in the screen.&lt;/p&gt;
&lt;p&gt;Whenever I clicked an image in the screen (which is called an Object inside Construct 2), the &amp;#8220;Properties&amp;#8221; tab changed with the options I could change for that object. That&amp;#8217;s how I found the &amp;#8220;Behaviors&amp;#8221; option and clicked it. After that a popup appeared so I could see the current behaviors on my object: none. I clicked the green plus image and it gave me a big popup to choose which behavior I wanted to add:&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/articles/085_construct2review/Behaviors.png" alt="Current behaviors in Construct 2" /&gt;&lt;/div&gt;
&lt;p&gt;I could see the &amp;#8220;Platform&amp;#8221;, &amp;#8220;Jump-thru&amp;#8221; and &amp;#8220;Solid&amp;#8221; behaviors, so that was enough for me to start adding behaviors to my objects. Once I finished adding them, I clicked the green arrow in the top of the screen, &amp;#8220;Run layout&amp;#8221;. Within minutes I already had a game with simple platformer mechanics in it! Impressive.&lt;/p&gt;
&lt;p&gt;Now I wanted to add an enemy to my platformer game, so I dragged in its image and tried to add a proper behavior to it. There wasn&amp;#8217;t any behavior that would be obvious for an enemy, so I was a bit lost. I right-clicked the object and found the &amp;#8220;Edit Event Sheet&amp;#8221; option. So I clicked it and tried adding an event, but nothing I tried would make the enemy work. The events don&amp;#8217;t have a good description, which makes them hard to use. I could do nothing but try to get help online (even the manual is online).&lt;/p&gt;
&lt;p&gt;After a couple hours of reading, I wanted to start a new project. Turns out that everything I did with the enemy image was &amp;#8220;wrong&amp;#8221;. There were much simpler solutions to what I wanted to do and I learned so many other things that I just wanted to start a new project and apply everything I learned. And so I did.&lt;/p&gt;
&lt;p&gt;My first experience with Construct 2 taught me that the tool is really great &amp;#8211; it really helps you to make games easily &amp;#8211; but some things are very complex at the moment, if you try to dive right in like I did. There isn&amp;#8217;t something that will walk you through the application once you start your first project and many things aren&amp;#8217;t descriptive enough. I wish that the initial screen either forced me to go read the tutorials online or provided me with a built-in walkthrough tutorial.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;The First Game&lt;/h2&gt;
&lt;p&gt;Turns out that once you read some of their guides and tutorials, everything is very easy (and if you&amp;#8217;re wondering which tutorials I read, they&amp;#8217;re linked at the bottom of this review). I found myself creating many layouts and event sheets, and quickly adding objects to the screen as if I was using the good old Flash IDE. However, I realized that Construct 2 doesn&amp;#8217;t have quick-align shortcuts as Flash does, and that makes it extremely hard and boring to align objects in the screen the way I want. Even using their built-in &amp;#8220;Snap to grid&amp;#8221; option didn&amp;#8217;t help me much, as my objects often had different sizes and proportions from each other.&lt;/p&gt;
&lt;p&gt;Animations are really easy to do. The tool allows me to import either many images which will be transformed into frames, or import a spritesheet that will be cropped to make frames. The only things I missed in it were the ability to add more than one image to the same frame, and an easy to use alignment system.&lt;/p&gt;
&lt;p&gt;Within an hour, I already had a very simple memory game in my screen. I only had to add the events that would control the game mechanics. And that was initially a big problem. Coming from a programming background, having to visually create the mechanics with events and a limited set of conditions was very hard. I felt I wasn&amp;#8217;t free to just go on and &amp;#8220;code&amp;#8221; anything I wanted in the game, and soon became upset with the event system. It was only after reading (yet another) tutorial on their site that I changed my mind.&lt;/p&gt;
&lt;p&gt;I found myself playing for two hours adding and removing events, changing conditions and actions. As soon as I understood how Construct 2&amp;#8242;s event system worked, it was a really fun challenge to &amp;#8220;program&amp;#8221; the events to do what I wanted, since I had only a set of limited conditions and actions to use. It was both challenging and relaxing to be able to visually organize your game and see it evolving without writing a single line of code!&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/articles/085_construct2review/FunWithEvents.png" alt="Fun with events in Construct 2" /&gt;&lt;br /&gt;The events for my memory game&lt;/div&gt;
&lt;p&gt;After 3 hours of learning and applying this new knowledge in the tool, I had finished my very first game with Construct 2. My conclusion? Construct 2 is a very powerful tool once you learn how to use it, otherwise you&amp;#8217;ll feel like a complete fool in front of it. I wish it was easier to use with more descriptive options, but after three hours I felt as if I was already a pro with the tool, because it was so easy to add, change and remove things!&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;My Conclusions&lt;/h2&gt;
&lt;p&gt;Construct 2 is a very interesting tool. For people who are already game developers, I found it can be a fun experience and it can teach you a few things about making things simpler, but it isn&amp;#8217;t a tool that I would use in my routine. Due to HTML5&amp;#8242;s still experimental nature, you&amp;#8217;ll find that some features that your game may require won&amp;#8217;t work properly across all devices. One example is audio: this simple memory game that I created uses only two sounds &amp;#8211; a background music and a card flip effect &amp;#8211; and yet I noticed differences between Firefox, Chrome and Android&amp;#8217;s browser (which just doesn&amp;#8217;t play audio).&lt;/p&gt;
&lt;p&gt;When it comes to using Construct 2 to help me expand my game to another platform, that&amp;#8217;s something you may want to think about first. It&amp;#8217;s very easy to just import all the images in there and set up everything, but the problem comes with events: you&amp;#8217;ll spend a lot of time organizing events to make them work the same way as your game in Flash (if that&amp;#8217;s the platform you first built your game in).&lt;/p&gt;
&lt;p&gt;However, Construct 2 can have a very interesting use for game developers: rapid prototyping and testing whether an idea is fun or not. Within minutes or hours you can just create a level or a small shooter game using behaviors and let people play it, giving feedback as to whether the prototype is fun or not.&lt;/p&gt;
&lt;p&gt;For people who want to get into making games but don&amp;#8217;t know or have trouble with programming, Construct 2 is  the perfect tool. You can quickly learn the event system and start making a game. Construct 2 can export your game to work within &lt;a href="http://www.kongregate.com" rel="external"&gt;Kongregate&lt;/a&gt; and on mobile devices. It&amp;#8217;s the perfect opportunity to make games and share with friends!&lt;/p&gt;
&lt;p&gt;Here is a quick list of pros and cons, based on my experience:&lt;/p&gt;
&lt;p&gt;Pros:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You can make a game within minutes&lt;/li&gt;
&lt;li&gt;The behavior system is very intuitive and easy to use&lt;/li&gt;
&lt;li&gt;You can make custom plugins for the tool, extending its abilities&lt;/li&gt;
&lt;li&gt;Once you learn how to use the event system, you feel like a pro using the tool&lt;/li&gt;
&lt;li&gt;Allows rapid prototyping&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Isn&amp;#8217;t descriptive enough&lt;/li&gt;
&lt;li&gt;You WILL have to read many tutorials and guides to properly use the tool&lt;/li&gt;
&lt;li&gt;Lacks many features for visually positioning and changing elements in the screen, such as quick aligning&lt;/li&gt;
&lt;li&gt;Exports only as an HTML5 game&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For people who are wondering whether or not the &amp;#8220;Standard&amp;#8221; version of the product is worth it: looking at the &lt;a href="https://www.scirra.com/store" rel="external"&gt;comparison table&lt;/a&gt;, the only drawbacks of the free version are the limited number of events (you will need many of them for a &amp;#8220;proper&amp;#8221; game) and the inability to offer your games as commercial products. &lt;/p&gt;
&lt;p&gt;The free version&amp;#8217;s limit on the number of layers you can have is arguably not a problem: I would easily manage to do everything in three layers; a fourth one would just make things easier. I don&amp;#8217;t think you would need more than that, unless you are creating something really big. My opinion: if you&amp;#8217;re just looking to make games for fun, the free version is more than enough. If you want to sell your games or get some money with them, the standard version is the way to go.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Extra Resources&lt;/h2&gt;
&lt;p&gt;Below is a quick list of the tutorials and guides that helped me a lot when learning the tool:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.scirra.com/tutorials/37/beginners-guide-to-construct-2" rel="external"&gt;Beginner&amp;#8217;s guide to Construct 2&lt;/a&gt; &amp;#8211; You won&amp;#8217;t do a thing within Construct 2 without this&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.scirra.com/tutorials/181/adding-sound-a-beginners-guide" rel="external"&gt;Adding sound &amp;#8211; a beginner&amp;#8217;s guide&lt;/a&gt; &amp;#8211; For people who want to use sounds in the game&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.scirra.com/tutorials/214/animation-control-event-based" rel="external"&gt;Animation Control &amp;#8211; Event Based&lt;/a&gt; &amp;#8211; Really helpful guide for animations and controlling them from a single place in the event sheet&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.scirra.com/tutorials/243/building-a-platform-game-a-beginners-guide" rel="external"&gt;Building a platform game &amp;#8211; a beginner&amp;#8217;s guide&lt;/a&gt; &amp;#8211; Useful for learning the basics of a platformer game within Construct 2&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.scirra.com/tutorials/245/how-to-series-in-game-shop" rel="external"&gt;How to series &amp;#8211; &amp;#8216;In Game Shop&amp;#8217;&lt;/a&gt; &amp;#8211; Perfect for learning how to organize your variables and event sheets&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.scirra.com/forum/about-picking_topic47216_page1.html" rel="external"&gt;About Picking&lt;/a&gt; &amp;#8211; For understanding how the events pick objects&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.scirra.com/forum/randomized-an-array-for-a-deck-of-cards_topic45833.html" rel="external"&gt;Randomized an array for a deck of cards&lt;/a&gt; &amp;#8211; For learning to use arrays within Construct 2&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And you can see the game I created within three hours here:&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;a href="http://d2fhka9tf2vaj2.cloudfront.net/articles/085_construct2review/ExportedGame/index.html"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/articles/085_construct2review/MemoryGame.png" alt="Construct 2 memory game" /&gt;&lt;/a&gt;&lt;br /&gt;Click to play&lt;/div&gt;
&lt;p&gt;The source files are available &lt;a href="http://d2fhka9tf2vaj2.cloudfront.net/articles/085_construct2review/MemoryGame.capx"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/QThsZF60MPetLo6MmsK0MUE1C_E/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QThsZF60MPetLo6MmsK0MUE1C_E/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/QThsZF60MPetLo6MmsK0MUE1C_E/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QThsZF60MPetLo6MmsK0MUE1C_E/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=Yh9C0OPPp7k:wlusV22VzOY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=Yh9C0OPPp7k:wlusV22VzOY:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=Yh9C0OPPp7k:wlusV22VzOY:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=Yh9C0OPPp7k:wlusV22VzOY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=Yh9C0OPPp7k:wlusV22VzOY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=Yh9C0OPPp7k:wlusV22VzOY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=Yh9C0OPPp7k:wlusV22VzOY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=Yh9C0OPPp7k:wlusV22VzOY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=Yh9C0OPPp7k:wlusV22VzOY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=Yh9C0OPPp7k:wlusV22VzOY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Flashtuts/~4/Yh9C0OPPp7k" height="1" width="1"/&gt;</description>
		<wfw:commentRss>http://active.tutsplus.com/articles/reviews/review-construct-2-a-drag-and-drop-html5-game-maker/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://active.tutsplus.com/articles/reviews/review-construct-2-a-drag-and-drop-html5-game-maker/</feedburner:origLink></item>
		<item>
		<title>Render an MP3 Audio Spectrum in Flash With computeSpectrum()</title>
		<link>http://feedproxy.google.com/~r/Flashtuts/~3/aeU57wBG4n8/</link>
		<comments>http://active.tutsplus.com/tutorials/media/render-an-mp3-audio-spectrum-in-flash-with-computespectrum/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 17:00:04 +0000</pubDate>
		<dc:creator>Amila Prabhath Senadheera</dc:creator>
				<category><![CDATA[Media]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[computeSpectrum]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[spectrum]]></category>
		<guid isPermaLink="false">http://active.tutsplus.com/?p=10808</guid>
		<description>&lt;p&gt;In this tutorial, I&amp;#8217;ll teach you how to create a visual representation of a sound file&amp;#8217;s audio spectrum, using Flash&amp;#8217;s &lt;code&gt;SoundMixer.computeSpectrum&lt;/code&gt; method. We&amp;#8217;ll use four classes for this effect: &lt;code&gt;Sound&lt;/code&gt;, &lt;code&gt;SoundChannel&lt;/code&gt;, &lt;code&gt;SoundMixer&lt;/code&gt;, and &lt;code&gt;ByteArray&lt;/code&gt;. I&amp;#8217;ll explain each classes as we use them.&lt;/p&gt;
&lt;p&gt;&lt;span id="more-10808"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;Final Result Preview&lt;/h2&gt;
&lt;p&gt;Let&amp;#8217;s take a look at the final result we will be working towards:&lt;/p&gt;
&lt;div class="tutorial_image"&gt;
&lt;a href="http://d2fhka9tf2vaj2.cloudfront.net/tuts/406_computeSpectrum/preview/SWFDemo.html?width=500&amp;#038;height=300&amp;#038;swfName=final_spectrum.swf"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/406_computeSpectrum/image7.jpg" /&gt;&lt;/a&gt;&lt;br /&gt;
Click to view the demo
&lt;/div&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 1:&lt;/span&gt; Set Up Your Flash File&lt;/h2&gt;
&lt;p&gt;Launch Flash Pro and create a new Flash Document. Set the stage size to 500x300px, the background color to #000000, and the frame rate to 24fps.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/406_computeSpectrum/image1.jpg" alt="Setup Stage " width="595" height="280" /&gt;&lt;/div&gt;
&lt;p&gt;In your timeline, select the existing layer and rename it &amp;#8220;Buttons&amp;#8221;. Then click &lt;em&gt;Window &gt; Common Libraries &gt; Buttons&lt;/em&gt;. &lt;/p&gt;
&lt;p&gt;Select your favorite button set, then drag and drop the &amp;#8216;Play&amp;#8217; and &amp;#8216;Stop&amp;#8217; buttons to the bottom-right corner of the stage.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/406_computeSpectrum/image2.jpg" alt="Library-Buttons" width="216" height="342" /&gt;&lt;/div&gt;
&lt;hr/&gt;
&lt;p&gt;Set the instance names of these buttons to &lt;em&gt;play_btn&lt;/em&gt; and &lt;em&gt;stop_btn&lt;/em&gt;, respectively.&lt;/p&gt;
&lt;h2&gt;&lt;span&gt;Step 2:&lt;/span&gt; Create the Document Class&lt;/h2&gt;
&lt;p&gt;Create a new AS file, and save it as &lt;em&gt;Main.as&lt;/em&gt;. Add this code (read the comments for more details):&lt;/p&gt;
&lt;p&gt;This code should be placed in our new Class:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
package  {
	import flash.display.Sprite;
	import flash.media.Sound; //The Sound class is the first step in working with sound. It is used to load a sound, play a sound, and manage basic sound properties.
	import flash.net.URLRequest;

	public class Main extends Sprite {
		private var sound:Sound;
		public function Main() {
			sound = new Sound(new URLRequest(&amp;quot;sound.mp3&amp;quot;)); //assign music to the sound variable.
			sound.play(); //play assigned sound.
		}
	}
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;You&amp;#8217;ll need to put an MP3 file called &lt;em&gt;sound.mp3&lt;/em&gt; in the same directory as your FLA&amp;#8217;s output directory. Any MP3 will do; on is included in the tutorial&amp;#8217;s source download.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 3: &lt;/span&gt;Document Class&lt;/h2&gt;
&lt;p&gt;Add the class name to the Class field in the Publish section of the Properties panel to associate the FLA with the Main document class.
&lt;p&gt;If you&amp;#8217;re not familiar with the concept of a document class,&lt;a href="http://active.tutsplus.com/tutorials/actionscript/quick-tip-how-to-use-a-document-class-in-flash/"&gt;check out this Quick Tip&lt;/a&gt; before reading further.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/406_computeSpectrum/image3.jpg" alt="Publish section" width="320" height="394" /&gt;&lt;/div&gt;
&lt;p&gt;Then press Ctrl+Enter to test your Application.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 4:&lt;/span&gt; Handling the Sound Using Buttons&lt;/h2&gt;
&lt;p&gt;Let&amp;#8217;s add an instance of a new class: &lt;code&gt;SoundChannel&lt;/code&gt;. This class is used to keep different sounds in separate audio channels; each channel is created by an instance of &lt;code&gt;SoundChannel&lt;/code&gt;, and we use these instances to control the sounds.&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
package  {
	import flash.display.Sprite;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.net.URLRequest;
	import flash.events.MouseEvent;
	public class Main extends Sprite {
		private var sound:Sound;
		private var channel:SoundChannel;

		public function Main() {
			sound = new Sound(new URLRequest(&amp;quot;sound.mp3&amp;quot;));
			play_btn.addEventListener(MouseEvent.CLICK,onPlayHandler);
			stop_btn.addEventListener(MouseEvent.CLICK,onStopHandler);
		}

		private function onPlayHandler(event:MouseEvent):void{
			channel = sound.play();
		}

		private function onStopHandler(event:MouseEvent):void{
			channel.stop();
		}
	}
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;As you can see, when Play is clicked, we don&amp;#8217;t just play the MP3, we also assign it to a SoundChannel. We can then control the playback through this SoundChannel instance later &amp;#8211; in this case, by making it stop.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 5:&lt;/span&gt; Create Simple Animation&lt;/h2&gt;
&lt;p&gt;Now let&amp;#8217;s create some simple animation for this sound, again using the SoundChannel class.&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
package  {
	import flash.display.Sprite;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.net.URLRequest;
	import flash.events.MouseEvent;
	import flash.events.Event;

	public class Main extends Sprite {

		private var sound:Sound;
		private var channel:SoundChannel;

		public function Main() {
			sound = new Sound(new URLRequest(&amp;quot;sound.mp3&amp;quot;));
			play_btn.addEventListener(MouseEvent.CLICK,onPlayHandler);
			stop_btn.addEventListener(MouseEvent.CLICK,onStopHandler);
		}

		private function onPlayHandler(event:MouseEvent):void{
			channel = sound.play();//assign sound to channel class
			addEventListener(Event.ENTER_FRAME,animateBars); //render the animation every frame
		}

		private function onStopHandler(event:MouseEvent):void{
			channel.stop();
			graphics.clear();
			removeEventListener(Event.ENTER_FRAME,animateBars);//stop rendering the animation
		}

		private function animateBars(event:Event):void{

			graphics.clear();

			graphics.beginFill(0xAB300C,1);
			//Draw a rectangle whose height corresponds to channel.leftPeak
			graphics.drawRect(190,300,50,-channel.leftPeak * 160 );
			graphics.endFill();

			graphics.beginFill(0xAB300C,1);
			//Draw a rectangle whose height corresponds to channel.rightPeak
			graphics.drawRect(250,300,50,-channel.rightPeak  * 160 );
			graphics.endFill();
		}
	}
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;leftPeak&lt;/code&gt; and &lt;code&gt;rightPeak&lt;/code&gt; properties of a &lt;code&gt;SoundChannel&lt;/code&gt; instance correspond to the current amplitude of the sound, through the left and right channels. Think of it this way: if you have stereo speakers, then &lt;code&gt;leftPeak&lt;/code&gt; is the volume of the sound coming out of the left speaker, and &lt;code&gt;rightPeak&lt;/code&gt; is the volume of the sound coming out of the right speaker.&lt;/p&gt;
&lt;p&gt;You can press Ctrl+Enter to test your application:&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/406_computeSpectrum/image4.jpg" alt="Sound Bar Animation" width="515" height="357" /&gt;&lt;/div&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 6:&lt;/span&gt; What Is SoundMixer?&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;SoundMixer&lt;/code&gt; class controls all embedded and streaming sounds in the application, for all SoundChannels at once. &lt;/p&gt;
&lt;p&gt;It has three methods: &lt;code&gt;areSoundsInaccessible()&lt;/code&gt;, which determines whether any sounds are inaccessible due to security reasons; &lt;code&gt;stopAll()&lt;/code&gt;, which stops playback of all sounds; and &lt;code&gt;computeSpectrum()&lt;/code&gt;, which is what we&amp;#8217;re interested in for this tutorial. The latter method takes a &amp;#8220;snapshot&amp;#8221; of the current sound, and pushes it into a ByteArray object.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 7:&lt;/span&gt; What Is ByteArray?&lt;/h2&gt;
&lt;p&gt;The ByteArray class provides methods and properties to optimize reading, writing, and working with binary data. It stores data as an array of bytes, hence its name. Find out more with this &lt;a href="http://active.tutsplus.com/tutorials/actionscript/introduction-to-bytearray/"&gt;Introduction to ByteArray&lt;/a&gt;.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 8:&lt;/span&gt; More Complex Animation&lt;/h2&gt;
&lt;p&gt;So now let&amp;#8217;s create a more complex animation using the &lt;code&gt;SoundMixer.computeSpectrum()&lt;/code&gt; method. Again, read the comments in the code to fully understand the behavior:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
package {
	import flash.display.Sprite;
	import flash.media.Sound;
	import flash.utils.ByteArray;
	import flash.events.Event;
	import flash.media.SoundMixer;
	import flash.filters.GlowFilter;
	import flash.net.URLRequest;
	import flash.events.MouseEvent;
	import flash.media.SoundChannel;

	public class Main extends Sprite{
		private var sound:Sound;
		private var channel:SoundChannel;
		private var byteArr:ByteArray = new ByteArray();
		private var glow:GlowFilter = new GlowFilter();
		private var filterArr:Array;
		private var line:Sprite = new Sprite();

		public function Main(){
			// create a &amp;quot;glow&amp;quot; effect for the animation we will render
			glow.color = 0x009900;
			glow.alpha = 1;
			glow.blurX = 10;
			glow.blurY = 10;

			// load your MP3 in to the Sound object
			sound = new Sound(new URLRequest(&amp;quot;sound.mp3&amp;quot;));
			// apply the glow effect
			filterArr = new Array(glow);
			line.filters = filterArr;
			addChild(line);

			play_btn.addEventListener(MouseEvent.CLICK,onPlayHandler);
			stop_btn.addEventListener(MouseEvent.CLICK,onStopHandler);
		}

		private function onPlayHandler(event:MouseEvent):void{
			channel = sound.play(0,1000);
			addEventListener(Event.ENTER_FRAME,spectrumHandler);
		}

		private function onStopHandler(event:MouseEvent):void{
			channel.stop();
			line.graphics.clear();
			removeEventListener(Event.ENTER_FRAME,spectrumHandler);
		}

		private function spectrumHandler(event:Event):void{
			line.graphics.clear();
			line.graphics.lineStyle(1,Math.random() * 0xFFFFFF);
			line.graphics.moveTo(-1,150);
			// push the spectrum's bytes into the ByteArray
			SoundMixer.computeSpectrum(byteArr);

			for (var i:uint=0; i&amp;lt;256; i++){
				// read bytes and translate to a number between 0 and +300
				var num:Number = byteArr.readFloat() * 150 + 150;
				//use this number to draw a line
				line.graphics.lineTo(i*2,num);
			}
		}
	}
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;The most important parts of this code are lines 53 and 57. Here, the whole sound wave is translated to a ByteArray, which is then read, byte by byte, and translated into a set of numbers.&lt;/p&gt;
&lt;p&gt;The ByteArray will be 512 floats long; in the &lt;code&gt;for&lt;/code&gt; loop, we only read the first 256 floats, which correspond to the entire sound wave of the left channel (the sound coming through the left speaker).&lt;/p&gt;
&lt;p&gt;Press Ctrl+Enter to test your Application.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/406_computeSpectrum/image5.jpg" alt="Sound Line Animation" width="517" height="358" /&gt;&lt;/div&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 9:&lt;/span&gt; Fill in the Gaps&lt;/h2&gt;
&lt;p&gt;We can fill in the area underneath the line to give us a different effect:&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/406_computeSpectrum/image6.jpg" alt="Complex Drawing Animation" width="516" height="358" /&gt;&lt;/div&gt;
&lt;p&gt;All we need to do is draw a box and fill it in, using &lt;code&gt;graphics&lt;/code&gt; methods. The code for this is as follows:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
package {
	import flash.display.Sprite;
	import flash.media.Sound;
	import flash.utils.ByteArray;
	import flash.events.Event;
	import flash.media.SoundMixer;
	import flash.filters.GlowFilter;
	import flash.net.URLRequest;
	import flash.events.MouseEvent;
	import flash.media.SoundChannel;

	public class Main extends Sprite{
		private var sound:Sound;
		private var channel:SoundChannel;
		private var byteArr:ByteArray = new ByteArray();
		private var glow:GlowFilter = new GlowFilter();
		private var filterArr:Array;
		private var line:Sprite = new Sprite();

		public function Main(){
			glow.color = 0xFF0000;
			glow.alpha = 1;
			glow.blurX = 10;
			glow.blurY = 10;

			sound = new Sound(new URLRequest(&amp;quot;sound.mp3&amp;quot;));

			filterArr = new Array(glow);
			line.filters = filterArr;
			addChild(line);
			addChild(play_btn);
			addChild(stop_btn);

			play_btn.addEventListener(MouseEvent.CLICK,onPlayHandler);
			stop_btn.addEventListener(MouseEvent.CLICK,onStopHandler);
		}

		private function onPlayHandler(event:MouseEvent):void{
			channel = sound.play(0,1000);
			addEventListener(Event.ENTER_FRAME,spectrumHandler);
		}

		private function onStopHandler(event:MouseEvent):void{
			channel.stop();
			line.graphics.clear();
			removeEventListener(Event.ENTER_FRAME,spectrumHandler);
		}

		private function spectrumHandler(event:Event):void{
			// draw one edge of the box, and specify a fill
			line.graphics.clear();
			line.graphics.beginFill(0xFF0000,1);
			line.graphics.lineStyle(1,0xFF0000);
			line.graphics.moveTo(-1,150);
			SoundMixer.computeSpectrum(byteArr);

			for (var i:uint=0; i&amp;lt;256; i++){
				var num:Number = byteArr.readFloat() * 200 + 150;
				line.graphics.lineTo(i*2,num);
			}

			//draw the rest of the box
			line.graphics.lineTo(512,300);
			line.graphics.lineTo(0,300);
			line.graphics.lineTo(-1,150);
		}
	}
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 10:&lt;/span&gt; Try Something Different&lt;/h2&gt;
&lt;p&gt;We can take this idea further, to add even more interesting and complex effects:&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/406_computeSpectrum/image7.jpg" alt="Complex Drawing Animation" width="516" height="357" /&gt;&lt;/div&gt;
&lt;p&gt;In this case, we&amp;#8217;ll draw two spectra on top of each other, one for the left channel and one for the right. To achieve this, we&amp;#8217;ll use two &lt;code&gt;for&lt;/code&gt; loops that each read in 256 floats, one after the other.&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
package {
	import flash.display.Sprite;
	import flash.media.Sound;
	import flash.utils.ByteArray;
	import flash.events.Event;
	import flash.media.SoundMixer;
	import flash.filters.GlowFilter;
	import flash.net.URLRequest;
	import flash.events.MouseEvent;
	import flash.media.SoundChannel;

	public class Main extends Sprite{
		private var sound:Sound;
		private var channel:SoundChannel;
		private var byteArr:ByteArray = new ByteArray();
		private var glow:GlowFilter = new GlowFilter();
		private var filterArr:Array;
		private var line:Sprite = new Sprite();
		private var num:Number;
		public const GRAFT_HEIGHT:int = 150; //set animation height
		public const CHANNEL_SIZE:int = 256; //set left/right channel size

		public function Main(){
			glow.color = 0x009900;
			glow.alpha = 1;
			glow.blurX = 10;
			glow.blurY = 10;

			sound = new Sound(new URLRequest(&amp;quot;sound.mp3&amp;quot;));

			filterArr = new Array(glow); //add glow to the animation
			line.filters = filterArr;
			addChild(line);

			play_btn.addEventListener(MouseEvent.CLICK,onPlayHandler);
			stop_btn.addEventListener(MouseEvent.CLICK,onStopHandler);
		}

		private function onPlayHandler(event:MouseEvent):void{
			channel = sound.play(0,1000); // play sound 1000 times
			addEventListener(Event.ENTER_FRAME,spectrumHandler);
		}

		private function onStopHandler(event:MouseEvent):void{
			channel.stop();
			line.graphics.clear();
			removeEventListener(Event.ENTER_FRAME,spectrumHandler);
		}

		private function spectrumHandler(event:Event):void{
			num = 0;

			line.graphics.clear(); // create current graphics
			line.graphics.lineStyle(0, 0x00FF00);
			line.graphics.beginFill(0x00FF00,0.5);
			line.graphics.moveTo(0,GRAFT_HEIGHT);

			SoundMixer.computeSpectrum(byteArr);// add bytes to Sound mixer

			for (var i:int = 0; i &amp;lt; CHANNEL_SIZE; i++) {
                		num = (byteArr.readFloat() * GRAFT_HEIGHT);
                		line.graphics.lineTo(i * 2, GRAFT_HEIGHT - num);
            		}

			line.graphics.lineTo(CHANNEL_SIZE * 2, GRAFT_HEIGHT);
			line.graphics.endFill();

			line.graphics.lineStyle(0, 0xFF0000);
			line.graphics.beginFill(0xFF0000, 0.5);
			line.graphics.moveTo(CHANNEL_SIZE * 2,GRAFT_HEIGHT);

			for (i = CHANNEL_SIZE; i &amp;gt; 0; i--) {
				num = (byteArr.readFloat() * GRAFT_HEIGHT);
				line.graphics.lineTo(i * 2, GRAFT_HEIGHT - num);
			}

			line.graphics.lineTo(0, GRAFT_HEIGHT);
			line.graphics.endFill();
		}
	}
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;So we have learnt how to use the various Sound classes, and how to create beautiful sound drawing animations using &lt;code&gt;SoundMixer&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Thank you for taking the time to read this article, because this is my first tutorial. If you have any questions, please leave them in a comment.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/kXemySrBrOmznhoBIeb0gH0EQhA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kXemySrBrOmznhoBIeb0gH0EQhA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/kXemySrBrOmznhoBIeb0gH0EQhA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kXemySrBrOmznhoBIeb0gH0EQhA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=aeU57wBG4n8:J8e5CpsBjkU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=aeU57wBG4n8:J8e5CpsBjkU:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=aeU57wBG4n8:J8e5CpsBjkU:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=aeU57wBG4n8:J8e5CpsBjkU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=aeU57wBG4n8:J8e5CpsBjkU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=aeU57wBG4n8:J8e5CpsBjkU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=aeU57wBG4n8:J8e5CpsBjkU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=aeU57wBG4n8:J8e5CpsBjkU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=aeU57wBG4n8:J8e5CpsBjkU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=aeU57wBG4n8:J8e5CpsBjkU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Flashtuts/~4/aeU57wBG4n8" height="1" width="1"/&gt;</description>
		<wfw:commentRss>http://active.tutsplus.com/tutorials/media/render-an-mp3-audio-spectrum-in-flash-with-computespectrum/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		<feedburner:origLink>http://active.tutsplus.com/tutorials/media/render-an-mp3-audio-spectrum-in-flash-with-computespectrum/</feedburner:origLink></item>
		<item>
		<title>Browser Extension: Arrange Tumblr Posts in Chronological Order</title>
		<link>http://feedproxy.google.com/~r/Flashtuts/~3/x5s4DR_bK4A/</link>
		<comments>http://active.tutsplus.com/tutorials/browser-extensions/browser-extension-arrange-tumblr-posts-in-chronological-order/#comments</comments>
		<pubDate>Sun, 05 Feb 2012 07:00:50 +0000</pubDate>
		<dc:creator>Michael James Williams</dc:creator>
				<category><![CDATA[Browser Extensions]]></category>
		<category><![CDATA[browser extensions]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[nodelist]]></category>
		<guid isPermaLink="false">http://active.tutsplus.com/?p=10796</guid>
		<description>&lt;p&gt;Creating little browser extensions is a great way to learn JavaScript. You don&amp;#8217;t need to worry about cross-browser compatibility, you can make the project as small or large as you like, and you can fix problems in other people&amp;#8217;s websites that bug you, specifically. In this post, we&amp;#8217;ll create a short script that automatically rearranges Tumblr archive pages to read in chronological order &amp;#8211; and we&amp;#8217;ll learn about &lt;code&gt;NodeList&lt;/code&gt; on the way.&lt;span id="more-10796"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;The Problem&lt;/h2&gt;
&lt;p&gt;This week, &lt;a href="http://qwantz.com" rel="external"&gt;Ryan North&lt;/a&gt; started &lt;a href="http://btothef.tumblr.com/" rel="external"&gt;a new Tumblr&lt;/a&gt;, in which he&amp;#8217;s going through the novelization of the first Back to the Future movie, one page at a time. This is a thing I wish to read.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;a href="http://btothef.tumblr.com/" rel="external"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/405_browserExtensionChronologicalTumblr/BtotheFMostRecentFirst.png" alt="BtotheF" /&gt;&lt;/a&gt;Click to read.&lt;/div&gt;
&lt;p&gt;However, Tumblr displays its posts in reverse chronological order &amp;#8211; that is, with the most recent posts first. This makes sense for a lot of sites on Tumblr, but in this instance, I really want to read them in the order they were written. The current site layout means that, to do that, I have to scroll down to the top of the first (first written) post, scroll down as I read it, and then scroll up to the top of the second post, and scroll down through that&amp;#8230;&lt;/p&gt;
&lt;p&gt;This is a tiny, tiny &lt;a href="http://knowyourmeme.com/memes/first-world-problems" rel="external"&gt;first world problem&lt;/a&gt; &amp;#8211; totally trivial and almost embarrassing to mention. But that doesn&amp;#8217;t mean I don&amp;#8217;t want to fix it.&lt;/p&gt;
&lt;p&gt;By the end of this tutorial, you&amp;#8217;ll make this Tumblr &amp;#8211; or any Tumblr you choose &amp;#8211; display its posts in chronological order on the page, automatically.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;How Can We Do This?&lt;/h2&gt;
&lt;p&gt;We don&amp;#8217;t have control over the BtotheF site design; it offers no options to us, so we can&amp;#8217;t change the order in which the posts are displayed on the page server-side.&lt;/p&gt;
&lt;p&gt;But once the HTML is sent to the browser, it&amp;#8217;s ours. We can manipulate it however we want. And, of course, the language with which we can do this is JavaScript.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ll give a quick demo. I&amp;#8217;ll be using &lt;a href="http://www.google.co.uk/chrome" rel="external"&gt;Chrome&lt;/a&gt;, and recommend that you do, too &amp;#8211; if you can&amp;#8217;t, or don&amp;#8217;t want to, then grab a copy of &lt;a href="http://getfirebug.com/" rel="external"&gt;Firebug&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Browse to &lt;a href="http://btothef.tumblr.com/" rel="external"&gt;http://btothef.tumblr.com/&lt;/a&gt; and open the JavaScript console (&lt;em&gt;Tools &gt; JavaScript Console&lt;/em&gt;, in Chrome). Type:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
alert(&amp;quot;Hi&amp;quot;);
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;&amp;#8230;and hit Enter.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/405_browserExtensionChronologicalTumblr/AlertDemo.png" alt="JavaScript Console Demo" /&gt;&lt;/div&gt;
&lt;p&gt;Wow! &amp;#8230; Okay, fine, that didn&amp;#8217;t prove much. Try this:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
document.body.appendChild(document.createTextNode(&amp;quot;Hi&amp;quot;));
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;This will take the HTML document&amp;#8217;s &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; element, and append a new text node &amp;#8211; a piece of text, basically &amp;#8211; containing the word &amp;#8220;Hi&amp;#8221;. If you didn&amp;#8217;t follow any of that, &lt;a href="http://active.tutsplus.com/tutorials/html5/get-up-to-speed-with-html-basix/"&gt;get up to speed with HTML&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To see the result, scroll right down to the bottom of the Tumblr:&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/405_browserExtensionChronologicalTumblr/LookItSaysHi.png" alt="JavaScript Console Demo" /&gt;&lt;/div&gt;
&lt;p&gt;Slightly more impressive, since we&amp;#8217;ve actually changed the contents of the page. The new text node is right at the bottom because we&amp;#8217;ve used &lt;code&gt;appendChild()&lt;/code&gt; &amp;#8211; which adds the specified node after everything else inside the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;. As far as our browser is concerned, the last few lines of HTML now look like this:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: xml; collapse: false; first-line: 1; title: ; notranslate"&gt;
&amp;lt;!-- END TUMBLR CODE --&amp;gt;

Hi
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;So! Now we have two issues:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;How do we use JavaScript to rearrange all the posts in the page?&lt;/li&gt;
&lt;li&gt;How do we make this happen automatically, without having to mess around in the console every time we read the Tumblr?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We&amp;#8217;ll address these in order.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;Rearranging the Posts&lt;/h2&gt;
&lt;p&gt;First, let&amp;#8217;s figure out how to &amp;#8220;find&amp;#8221; all of the posts in the HTML. In Chrome, right-click somewhere in the top post, and select &amp;#8220;Inspect element&amp;#8221;. (Firebug should add the same shortcut to Firefox; for other browsers, try the magnifying glass icon.)&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/405_browserExtensionChronologicalTumblr/InspectElement.png" alt="Inspect Element (Chrome)" /&gt;&lt;/div&gt;
&lt;p&gt;The Elements tab of the Developer Tools will appear, with the element you selected highlighted:&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/405_browserExtensionChronologicalTumblr/Elements_content_text.png" alt="Elements Tab" /&gt;&lt;/div&gt;
&lt;p&gt;As you hover over different elements in this HTML view, you&amp;#8217;ll see them highlighted in the page itself. Eventually, you&amp;#8217;ll find that the entire post is contained in a &lt;code&gt;div&lt;/code&gt; with a class of &lt;code&gt;post&lt;/code&gt;. As you can see from the screenshot above, there are several other such &lt;code&gt;div&lt;/code&gt; elements, and they are all contained in a master div with an id of &lt;code&gt;contents&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;We can select all of these post elements at once with a single line of code; type this into the JavaScript console:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
document.getElementById(&amp;quot;contents&amp;quot;).getElementsByClassName(&amp;quot;post&amp;quot;);
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;(Technically, we could have just written &lt;code&gt;document.getElementsByClassName("post")&lt;/code&gt;, but who cares?)&lt;/p&gt;
&lt;p&gt;You&amp;#8217;ll see &amp;#8211; again, in Chrome &amp;#8211; some feedback:&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/405_browserExtensionChronologicalTumblr/AllThePosts.png" alt="All the posts" /&gt;&lt;/div&gt;
&lt;p&gt;Great! This indicates that it worked. If you click the arrows, you&amp;#8217;ll see the contents of each &lt;code&gt;div&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;We might as well assign this to a variable, to save us having to type it out over and over:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
var posts = document.getElementById(&amp;quot;contents&amp;quot;).getElementsByClassName(&amp;quot;post&amp;quot;);
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;(This time, the console will return &lt;code&gt;undefined&lt;/code&gt;; you can check that it assigned the variable correctly by just typing the word &lt;code&gt;posts&lt;/code&gt; in the console.)&lt;/p&gt;
&lt;p&gt;We can loop through all of the elements in &lt;code&gt;posts&lt;/code&gt; as if it were an array:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
for (var i=0; i &amp;lt; posts.length; i++) {
     console.log(posts[i]);
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Hit Shift-Enter to add a new line to your code without running it, in the JavaScript console. &lt;code&gt;console.log()&lt;/code&gt; just traces its contents to the console, which is far less annoying than an &lt;code&gt;alert()&lt;/code&gt; and far less disruptive than adding text to the HTML DOM.&lt;/p&gt;
&lt;p&gt;The result of this simple loop will just be a list of all the &lt;code&gt;div&lt;/code&gt; elements. Cool. So presumably we can do something like this&amp;#8230;&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
var numPosts = posts.length;
for (var i=numPosts - 1; i &amp;gt;= 0; i--) {
     posts.push(posts[i]);
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Try it out! You&amp;#8217;ll see this:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: plain; collapse: false; first-line: 1; title: ; notranslate"&gt;
TypeError: Object #&amp;lt;NodeList&amp;gt; has no method 'push'
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Rats.&lt;/p&gt;
&lt;h3&gt;A NodeList Is Not an Array&lt;/h3&gt;
&lt;p&gt;When we use &lt;code&gt;getElementsByClassName()&lt;/code&gt;, we don&amp;#8217;t retrieve a simple array of elements, we retrieve a &lt;a href="https://developer.mozilla.org/En/DOM/NodeList" rel="external"&gt;NodeList&lt;/a&gt;. Like an array, this is a collection of elements; unlike an array, the collection is updated in real time. If the HTML DOM is modified, the contents of &lt;code&gt;posts&lt;/code&gt; gets modified to match.&lt;/p&gt;
&lt;p&gt;For example, let&amp;#8217;s create a new div with a class of &lt;code&gt;post&lt;/code&gt; and append it to the &lt;code&gt;contents&lt;/code&gt; div:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
var newPostDiv = document.createElement(&amp;quot;div&amp;quot;);
newPostDiv.setAttribute(&amp;quot;class&amp;quot;, &amp;quot;post&amp;quot;);
document.getElementById(&amp;quot;contents&amp;quot;).appendChild(newPostDiv);
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Run that, then type &lt;code&gt;posts&lt;/code&gt; and hit Enter. You&amp;#8217;ll see an extra &lt;code&gt;div&lt;/code&gt; in the list &amp;#8211; even though we haven&amp;#8217;t touched the &lt;code&gt;posts&lt;/code&gt; variable.&lt;/p&gt;
&lt;p&gt;Since a &lt;code&gt;NodeList&lt;/code&gt; is not an array, it doesn&amp;#8217;t have most of the methods and properties of &lt;code&gt;Array&lt;/code&gt;, such as &lt;code&gt;push()&lt;/code&gt; In fact, we&amp;#8217;ve already used the only property: &lt;code&gt;length&lt;/code&gt;. The only method is &lt;code&gt;.item(n)&lt;/code&gt;, which just gets the &lt;code&gt;n&lt;/code&gt;th item in the list.&lt;/p&gt;
&lt;p&gt;However, our earlier demonstration with &lt;code&gt;appendChild()&lt;/code&gt; does suggest an alternative solution: what if, instead of trying to rearrange the elements of the &lt;code&gt;NodeList&lt;/code&gt; within the &lt;code&gt;NodeList&lt;/code&gt;, we rearranged them within the page?&lt;/p&gt;
&lt;p&gt;First, we&amp;#8217;ll run through the list in reverse order, and append each element in turn to the &lt;code&gt;contents&lt;/code&gt; div; then, we&amp;#8217;ll remove the original posts.&lt;/p&gt;
&lt;p&gt;Refresh the Tumblr page to clear out all the extra rubbish we&amp;#8217;ve added to the DOM, then do the first step, of adding the elements in reverse order:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
//have to define posts again, since we lost it when we refreshed
var posts = document.getElementById(&amp;quot;contents&amp;quot;).getElementsByClassName(&amp;quot;post&amp;quot;);
var numPosts = posts.length;
for (var i=numPosts - 1; i &amp;gt;= 0; i--) {
     document.getElementById(&amp;quot;contents&amp;quot;).appendChild(posts[i]);
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Okay, now we&amp;#8230; wait, what?&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/405_browserExtensionChronologicalTumblr/BtotheFLastPostFirst.png" alt="description of image" /&gt;&lt;/div&gt;
&lt;p&gt;The (chronological) first post is already at the top, and the last post is at the bottom, with no posts repeated. This may seem surprising, but it makes sense: we didn&amp;#8217;t &lt;em&gt;clone&lt;/em&gt; any elements of the &lt;code&gt;NodeList&lt;/code&gt;, we just appended them to the &lt;code&gt;contents&lt;/code&gt; div, in reverse order. Since the &lt;code&gt;NodeList&lt;/code&gt; always reflects the contents of the HTML DOM, we just &lt;em&gt;moved&lt;/em&gt; each of the 11 elements to a new position &amp;#8211; the 11th element got added to the end (no change in position); then the 10th got moved to be after that; the 9th after that, and so on, until the 1st element was right at the end.&lt;/p&gt;
&lt;p&gt;So, problem solved, in five simple lines of code. Now let&amp;#8217;s automate it.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;Turning It Into a Browser Extension&lt;/h2&gt;
&lt;p&gt;Three of the top four browsers allow you to create browser extensions &amp;#8211; installable add-ons &amp;#8211; using JavaScript. (It will not surprise you to learn that Internet Explorer is the exception.) Here are the &lt;a href="http://code.google.com/chrome/extensions/overview.html" rel="external"&gt;instructions for Chrome&lt;/a&gt;, the &lt;a href="https://developer.mozilla.org/en/Extensions" rel="external"&gt;instructions for Firefox&lt;/a&gt;, and the &lt;a href="https://developer.apple.com/library/safari/#documentation/Tools/Conceptual/SafariExtensionGuide/Introduction/Introduction.html" rel="external"&gt;instructions for Safari&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But we&amp;#8217;re not going to use any of those. Instead, we&amp;#8217;ll use a great add-on called Greasemonkey, which allows you to install little JS scripts without needing to package them up as full-blown browser extensions. Essentially, it injects snippets of JavaScript into the page, once it&amp;#8217;s loaded.&lt;/p&gt;
&lt;p&gt;Chrome already has Greasemonkey support baked in. Opera has something very similar to Greasemonkey baked in: &lt;a href="http://www.opera.com/docs/userjs/" rel="external"&gt;UserJS&lt;/a&gt;. For Firefox, you&amp;#8217;ll need to &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/" rel="external"&gt;install the Greasemonkey extension&lt;/a&gt;. For Safari, install &lt;a href="http://www.culater.net/software/SIMBL/SIMBL.php" rel="external"&gt;SIMBL&lt;/a&gt;, and then &lt;a href="http://8-p.info/greasekit/" rel="external"&gt;GreaseKit&lt;/a&gt;. For IE, install &lt;a href="http://www.ie7pro.com/" rel="external"&gt;IE7Pro&lt;/a&gt; or &lt;a href="http://www.bhelpuri.net/Trixie/default.htm" rel="external"&gt;Trixie&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Writing the Greasemonkey Script&lt;/h3&gt;
&lt;p&gt;Create a new text file, and name it &lt;code&gt;ChronologicalTumblr.user.js&lt;/code&gt;. Make sure you remove the default &lt;code&gt;.txt&lt;/code&gt; extension, and that you use &lt;code&gt;.user.js&lt;/code&gt;, rather than just &lt;code&gt;.js&lt;/code&gt; &amp;#8211; this is the extension for a Greasemonkey script.&lt;/p&gt;
&lt;p&gt;Copy our post rearrangement code into the file:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
var posts = document.getElementById(&amp;quot;contents&amp;quot;).getElementsByClassName(&amp;quot;post&amp;quot;);
var numPosts = posts.length;
for (var i=numPosts - 1; i &amp;gt;= 0; i--) {
     document.getElementById(&amp;quot;contents&amp;quot;).appendChild(posts[i]);
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Now, we need to add some extra metadata at the top of the script &amp;#8211; details about the script itself. All these details should go in comments, starting with &lt;code&gt;==UserScript==&lt;/code&gt; and ending with &lt;code&gt;==/UserScript==&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
// ==UserScript==
//
// ==/UserScript==

var posts = document.getElementById(&amp;quot;contents&amp;quot;).getElementsByClassName(&amp;quot;post&amp;quot;);
var numPosts = posts.length;
for (var i=numPosts - 1; i &amp;gt;= 0; i--) {
     document.getElementById(&amp;quot;contents&amp;quot;).appendChild(posts[i]);
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;First, we&amp;#8217;ll add a name and a description:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
// ==UserScript==
// @name          Chronological Tumblr
// @description	  Displays Tumblr posts in chronological order
// ==/UserScript==

var posts = document.getElementById(&amp;quot;contents&amp;quot;).getElementsByClassName(&amp;quot;post&amp;quot;);
var numPosts = posts.length;
for (var i=numPosts - 1; i &amp;gt;= 0; i--) {
     document.getElementById(&amp;quot;contents&amp;quot;).appendChild(posts[i]);
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Then, we&amp;#8217;ll specify a &lt;em&gt;namespace&lt;/em&gt;. The combination of the name and the namespace is what uniquely identifies the script; if you try to install another Greasemonkey script with the same name &lt;em&gt;and&lt;/em&gt; namespace as an existing script, it will overwrite the old one &amp;#8211; if only the name &lt;em&gt;or&lt;/em&gt; the namespace match, it&amp;#8217;ll just install the new one alongside the old. &lt;/p&gt;
&lt;p&gt;It&amp;#8217;s common to use a URL here, so I&amp;#8217;ll use Activetuts+&amp;#8217;s. You should use your own, since you&amp;#8217;re in control of it:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
// ==UserScript==
// @name          Chronological Tumblr
// @description	  Displays Tumblr posts in chronological order
// @namespace      http://active.tutsplus.com/
// ==/UserScript==

var posts = document.getElementById(&amp;quot;contents&amp;quot;).getElementsByClassName(&amp;quot;post&amp;quot;);
var numPosts = posts.length;
for (var i=numPosts - 1; i &amp;gt;= 0; i--) {
     document.getElementById(&amp;quot;contents&amp;quot;).appendChild(posts[i]);
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Now we need to specify which URLs this script should affect &amp;#8211; that is, on which web pages the JavaScript should automatically be injected into. I want this script to work on the BtotheF homepage, plus the other archive pages, like &lt;a href="http://btothef.tumblr.com/page/2" rel="external"&gt;http://btothef.tumblr.com/page/2&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
// ==UserScript==
// @name          Chronological Tumblr
// @description	  Displays Tumblr posts in chronological order
// @namespace      http://active.tutsplus.com/
// @include       http://btothef.tumblr.com/
// @include       http://btothef.tumblr.com/page/*
// ==/UserScript==

var posts = document.getElementById(&amp;quot;contents&amp;quot;).getElementsByClassName(&amp;quot;post&amp;quot;);
var numPosts = posts.length;
for (var i=numPosts - 1; i &amp;gt;= 0; i--) {
     document.getElementById(&amp;quot;contents&amp;quot;).appendChild(posts[i]);
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;*&lt;/code&gt; is a wildcard; it ensures that the script will be inserted into every single archive page of the BtotheF Tumblr. &lt;/p&gt;
&lt;p&gt;We could use a wildcard to make every single Tumblr&amp;#8217;s archive pages display in chronological order:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; highlight: [5,6]; title: ; notranslate"&gt;
// ==UserScript==
// @name          Chronological Tumblr
// @description	  Displays Tumblr posts in chronological order
// @namespace      http://active.tutsplus.com/
// @include       http://*.tumblr.com/
// @include       http://*.tumblr.com/page/*
// ==/UserScript==

var posts = document.getElementById(&amp;quot;contents&amp;quot;).getElementsByClassName(&amp;quot;post&amp;quot;);
var numPosts = posts.length;
for (var i=numPosts - 1; i &amp;gt;= 0; i--) {
     document.getElementById(&amp;quot;contents&amp;quot;).appendChild(posts[i]);
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;In this case, it might be a good idea to improve your script to insert a button or link into the page that rearranges the posts when clicked. That way, you can use it when appropriate, without having to manually add every single Tumblr&amp;#8217;s URL as an &lt;code&gt;@include&lt;/code&gt; parameter.&lt;/p&gt;
&lt;p&gt;There are other &lt;a href="http://wiki.greasespot.net/Metadata_Block" rel="external"&gt;metadata parameters&lt;/a&gt; you could add, but this is all we need for now.&lt;/p&gt;
&lt;h3&gt;Finishing Off&lt;/h3&gt;
&lt;p&gt;Installing the script in Chrome is easy: just drag and drop it from your hard drive into a browser window. It&amp;#8217;ll warn you that scripts could potentially be dangerous (just click Continue), and then check again that you want to install this specific one:&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/405_browserExtensionChronologicalTumblr/ReallyInstall.png" alt="Are you sure?" /&gt;&lt;/div&gt;
&lt;p&gt;Hit Install. If you&amp;#8217;re using another browser, refer to the relevant Greasemonkey script&amp;#8217;s manual &amp;#8211; in any case, it&amp;#8217;ll be simple.&lt;/p&gt;
&lt;p&gt;Once it&amp;#8217;s installed, you can see it in your list of extensions:&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/405_browserExtensionChronologicalTumblr/LikeARealExtension.png" alt="Just like any other extension." /&gt;&lt;/div&gt;
&lt;p&gt;Head back to &lt;a href="http://btothef.tumblr.com/" rel="external"&gt;http://btothef.tumblr.com/&lt;/a&gt;, or hit refresh if you still have it open.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/405_browserExtensionChronologicalTumblr/BtotheFLastPostFirst.png" alt="description of image" /&gt;&lt;/div&gt;
&lt;p&gt;The posts are now automatically displaying in chronological order!&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s not perfect: you may have noticed that the navigation buttons have been moved to the top of the page, since they are contained in a div with a class of &lt;code&gt;post&lt;/code&gt;. But hey &amp;#8211; if that bugs you, you have the tools to fix it now.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/wBNuBN-lDKmAOOIbr_MAwDkLAuQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wBNuBN-lDKmAOOIbr_MAwDkLAuQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/wBNuBN-lDKmAOOIbr_MAwDkLAuQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wBNuBN-lDKmAOOIbr_MAwDkLAuQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=x5s4DR_bK4A:fwMLPA2iTec:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=x5s4DR_bK4A:fwMLPA2iTec:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=x5s4DR_bK4A:fwMLPA2iTec:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=x5s4DR_bK4A:fwMLPA2iTec:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=x5s4DR_bK4A:fwMLPA2iTec:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=x5s4DR_bK4A:fwMLPA2iTec:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=x5s4DR_bK4A:fwMLPA2iTec:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=x5s4DR_bK4A:fwMLPA2iTec:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=x5s4DR_bK4A:fwMLPA2iTec:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=x5s4DR_bK4A:fwMLPA2iTec:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Flashtuts/~4/x5s4DR_bK4A" height="1" width="1"/&gt;</description>
		<wfw:commentRss>http://active.tutsplus.com/tutorials/browser-extensions/browser-extension-arrange-tumblr-posts-in-chronological-order/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://active.tutsplus.com/tutorials/browser-extensions/browser-extension-arrange-tumblr-posts-in-chronological-order/</feedburner:origLink></item>
		<item>
		<title>Quick Tip: How to Debug an AS3 Error #1203</title>
		<link>http://feedproxy.google.com/~r/Flashtuts/~3/AEv0YPmbQYU/</link>
		<comments>http://active.tutsplus.com/tutorials/actionscript/quick-tip-how-to-debug-an-as3-error-1203/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 08:00:40 +0000</pubDate>
		<dc:creator>Dru Kepple</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[1203]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[Basix]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://active.tutsplus.com/?p=10787</guid>
		<description>&lt;p&gt;In this Quick Tip, we&amp;#8217;ll discuss the confusing AS3 error 1203, &amp;#8220;no constructor found&amp;#8221;, which crops up without provocation and is rather unfortunately worded.  We&amp;#8217;ll examine the scenario in which it will appear, and how to fix it.&lt;/p&gt;
&lt;p&gt;&lt;span id="more-10787"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="step_an_obligatory_but_somewhat_useless_description_of_error_1203"&gt;&lt;span&gt;Step 1:&lt;/span&gt; An Obligatory But Somewhat Useless Description of Error 1203&lt;/h2&gt;
&lt;p&gt;First, here is the language of the error:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: plain; title: ; notranslate"&gt;
1203: No default constructor found in base class flash.display:BitmapData.
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;It&amp;#8217;s difficult to break this down into plain English.  So let&amp;#8217;s next move on to a scenario that produces this error.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="step_a_busted_project"&gt;&lt;span&gt;Step 2:&lt;/span&gt; A Busted Project&lt;/h2&gt;
&lt;p&gt;You can find this project in the download package, in the folder &amp;#8220;&lt;em&gt;busted&lt;/em&gt;&amp;#8220;.  It consists of the following (which you can use to re-create this project if you prefer a hands-on approach):&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A FLA named &lt;em&gt;Busted.fla&lt;/em&gt;. It is empty, but is linked to the document class described next.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A document class named &lt;em&gt;Busted.as&lt;/em&gt;.  This extends &lt;code&gt;Sprite&lt;/code&gt; and simply creates an instance of the class described next, and adds it to the stage.&lt;br /&gt;
    The contents of the class are as follows:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
    package {
        import flash.display.*;
        public class Busted extends Sprite {
            public function Busted() {
                var bmp:Bitmap = new Bitmap(new BustedBitmap());
                addChild(bmp);
            }
        }
    }
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;BustedBitmap&lt;/code&gt; class extends &lt;code&gt;BitmapData&lt;/code&gt;, and so we use it to feed a &lt;code&gt;Bitmap&lt;/code&gt; object, which is then added to the stage.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Another class file named &lt;em&gt;BustedBitmap.as&lt;/em&gt;.  As mentioned previously, this extends &lt;code&gt;BitmapData&lt;/code&gt;, and its purpose is to be a &lt;code&gt;BitmapData&lt;/code&gt; that automatically supplies itself with some Perlin noise.  Its contents are:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
    package {
        import flash.display.*;
        public class BustedBitmap extends BitmapData {
            public function BustedBitmap() {
                perlinNoise(100, 100, 2, 1024, false, false, 7, true);
            }
        }
    }
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;So, in the &lt;code&gt;BustedBitmap&lt;/code&gt; constructor, we call &lt;code&gt;perlinNoise()&lt;/code&gt; and thus we automatically have something interesting in the pixel data, so we can see something right away when displaying on the stage.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now, go ahead and test the movie.  You will get Error 1203, pointed at line 4 of &lt;em&gt;BustedBitmap.as&lt;/em&gt;. And line 4 is&amp;#8230;&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; first-line: 4; title: ; notranslate"&gt;

public function BustedBitmap() {
&lt;/pre&gt;
&lt;/pre&gt;
&lt;hr /&gt;
&lt;h2 id="step_what8217s_all_this_then"&gt;&lt;span&gt;Step 3:&lt;/span&gt; What&amp;#8217;s All This, Then?&lt;/h2&gt;
&lt;p&gt;So what happened?  The big thing to keep in mind is that we&amp;#8217;re writing a class that is a subclass of another class (&lt;code&gt;BitmapData&lt;/code&gt; in this case).  Also keep in mind that when a class is instantiated, the constructor is called as part of the &amp;#8220;&lt;code&gt;new&lt;/code&gt;&amp;#8221; process.&lt;/p&gt;
&lt;p&gt;If you do not actually write a constructor, ActionScript will imply one for you.  It will look like this:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
public function [NameOfClass]() {

}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Where &amp;#8220;&lt;code&gt;[NameOfClass]&lt;/code&gt;&amp;#8221; will match the name of your class.&lt;/p&gt;
&lt;p&gt;Similarly, if you write a subclass, and don&amp;#8217;t call &lt;code&gt;super()&lt;/code&gt; in it, then ActionScript will imply that call for you, as well.  It will look like this:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
public function [NameOfSubclass]() {
    super();
    // Other explicit code in subclass constructor
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Note that it happens on the first line, and is simply a call to &lt;code&gt;super&lt;/code&gt; with no arguments.&lt;/p&gt;
&lt;p&gt;Finally, we get to the root of the problem.  If your subclass omits an explicit call to &lt;code&gt;super&lt;/code&gt;, and your superclass&amp;#8217;s constructor has required parameters, then your implicit call to &lt;code&gt;super&lt;/code&gt; does not supply the required parameters.  You&amp;#8217;d think that an argument mismatch error could catch this, but consider that since there isn&amp;#8217;t any code actually written to make the mismatch, ActionScript can only complain that the lack of a default constructor.&lt;/p&gt;
&lt;p&gt;In our example, &lt;code&gt;BustedBitmap&lt;/code&gt; extend &lt;code&gt;BitmapData&lt;/code&gt;, which has a constructor defined in the documentation as so:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
BitmapData(width:int, height:int, transparent:Boolean = true, fillColor:uint = 0xFFFFFFFF)
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;The first two parameters are required, and we&amp;#8217;re not supplying them.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="step_it8217s_as_simple_as8230"&gt;&lt;span&gt;Step 4:&lt;/span&gt; It&amp;#8217;s as Simple As&amp;#8230;&lt;/h2&gt;
&lt;p&gt;The solution is, once you understand the problem, extremely simple.  You need to explicitly call the super constructor, at least if there are required parameters.  In other words, in our &lt;code&gt;BustedBitmap&lt;/code&gt; class, this following highlighted line will fix the problem:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; highlight: [5]; title: ; notranslate"&gt;
package {
    import flash.display.*;
    public class BustedBitmap extends BitmapData {
        public function BustedBitmap() {
            super(600, 400);
            perlinNoise(100, 100, 2, 1024, false, false, 7, true);
        }
    }
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;And that will do it.&lt;/p&gt;
&lt;p&gt;As a teachable moment, I&amp;#8217;d like to add that, when extending another class, it&amp;#8217;s generally a good idea to include the explicit call to &lt;code&gt;super&lt;/code&gt;.  Even if there are no parameters at all, required or otherwise (as in &lt;code&gt;Sprite&lt;/code&gt; or &lt;code&gt;MovieClip&lt;/code&gt;), an explicit call can declare intention and awareness of the nature of the subclass.  More practically, explicit calls give you an opportunity to run some code prior to the call to &lt;code&gt;super&lt;/code&gt;, which may be helpful in certain situations.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id="step_8230and_that_is_all"&gt;&lt;span&gt;Step 5:&lt;/span&gt; &amp;#8230;And That Is All&lt;/h2&gt;
&lt;p&gt;Yet another error demystified; the challenge for this one is that the real cause of the error is quite buried.  Once you become handy with a shovel, though, the fix is easy enough.&lt;/p&gt;
&lt;p&gt;Thanks for reading, and be ready for more debugging tips.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/mwkPJcTl3M_Im5Mq_pTqJIPAsok/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mwkPJcTl3M_Im5Mq_pTqJIPAsok/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/mwkPJcTl3M_Im5Mq_pTqJIPAsok/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mwkPJcTl3M_Im5Mq_pTqJIPAsok/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=AEv0YPmbQYU:yE98jx4e5GU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=AEv0YPmbQYU:yE98jx4e5GU:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=AEv0YPmbQYU:yE98jx4e5GU:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=AEv0YPmbQYU:yE98jx4e5GU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=AEv0YPmbQYU:yE98jx4e5GU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=AEv0YPmbQYU:yE98jx4e5GU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=AEv0YPmbQYU:yE98jx4e5GU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=AEv0YPmbQYU:yE98jx4e5GU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=AEv0YPmbQYU:yE98jx4e5GU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=AEv0YPmbQYU:yE98jx4e5GU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Flashtuts/~4/AEv0YPmbQYU" height="1" width="1"/&gt;</description>
		<wfw:commentRss>http://active.tutsplus.com/tutorials/actionscript/quick-tip-how-to-debug-an-as3-error-1203/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://active.tutsplus.com/tutorials/actionscript/quick-tip-how-to-debug-an-as3-error-1203/</feedburner:origLink></item>
		<item>
		<title>Best of Tuts+ in January 2012</title>
		<link>http://feedproxy.google.com/~r/Flashtuts/~3/YCpxT3ZBypM/</link>
		<comments>http://active.tutsplus.com/articles/news/best-of-tuts-in-january-2012/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 08:00:18 +0000</pubDate>
		<dc:creator>David Appleyard</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[bestof]]></category>
		<category><![CDATA[monthlypicks]]></category>
		<guid isPermaLink="false">http://active.tutsplus.com/?p=10782</guid>
		<description>&lt;p&gt;Each month, we bring together a selection of the best tutorials and articles from across the whole &lt;a href="http://tutsplus.com/"&gt;Tuts+ network&lt;/a&gt;. Whether you&amp;#8217;d like to read the top posts from your favourite site, or would like to start learning something completely new, this is the best place to start!&lt;/p&gt;
&lt;p&gt;&lt;span id="more-10782"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Psdtuts+ — Photoshop Tutorials&lt;/h2&gt;
&lt;ul class="webroundup"&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
			&lt;img src="http://d2f8dzk2mhcqts.cloudfront.net/0808_Truck/preview.jpg" alt="Create a Pimped Out Truck Using Photoshop and Point and Shoot Photos" width="200" height="200" /&gt;
		&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://psd.tutsplus.com/tutorials/photo-effects-tutorials/pimped-out-truck/'&gt;Create a Pimped Out Truck Using Photoshop and Point and Shoot Photos&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Making modifications to your car or truck in Photoshop can be a lot of fun. In this tutorial we will demonstrate how to create a pimped out truck modification using photos taken with a simple point and shoot camera, with no advanced lighting setup. Let&amp;#8217;s get started!&lt;/p&gt;
&lt;p&gt;&lt;a href='http://psd.tutsplus.com/tutorials/photo-effects-tutorials/pimped-out-truck/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
			&lt;img src="http://d2f8dzk2mhcqts.cloudfront.net/0806_Elephant/preview.jpg" alt="Create an Elephant Sundae Using Photo Manipulation Techniques" width="200" height="200" /&gt;
		&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://psd.tutsplus.com/tutorials/photo-effects-tutorials/elephant-sundae/'&gt;Create an Elephant Sundae Using Photo Manipulation Techniques&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Photoshop is great at seamlessly combing photos to create an entirely new scene. In this tutorial we will create an elephant sundae using several stock photos. Let&amp;#8217;s get started!&lt;/p&gt;
&lt;p&gt;&lt;a href='http://psd.tutsplus.com/tutorials/photo-effects-tutorials/elephant-sundae/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
			&lt;img src="http://d2f8dzk2mhcqts.cloudfront.net/0818_Michaelo/preview.jpg" alt="The Incredible Digital Art of Michael Oswald" width="200" height="200" /&gt;
		&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://psd.tutsplus.com/articles/inspiration/michael-oswald/'&gt;The Incredible Digital Art of Michael Oswald&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;In this article we will be featuring the work of &lt;a href="http://www.bymichaelo.com/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','www.bymichaelo.com']);"&gt;Michael Oswald&lt;/a&gt;. Oswald is a digital artist with a unique style. His technique involves a combination of photo manipulation and digital painting techniques and the results are often stunning. Let&amp;#8217;s take a look!&lt;/p&gt;
&lt;p&gt;&lt;a href='http://psd.tutsplus.com/articles/inspiration/michael-oswald/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;hr /&gt;
&lt;h2&gt;Nettuts+ — Web Development Tutorials&lt;/h2&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d2o0t5hpnwv4c1.cloudfront.net/1038_sublime/sublime-text-2-tips-and-tricks.jpg" alt="Sublime Text 2 Tips and Tricks (Updated)" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://net.tutsplus.com/tutorials/tools-and-tips/sublime-text-2-tips-and-tricks/'&gt;Sublime Text 2 Tips and Tricks (Updated)&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;&lt;a href="http://www.sublimetext.com/dev" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','www.sublimetext.com']);"&gt;Sublime Text 2&lt;/a&gt; is one of the fastest and most incredible code editors to be released in a long time! With a community and plugin ecosystem as passionate as this one, it just might be impossible for any other editor to catch up. I&amp;#8217;ll show you my favorite tips and tricks today. &lt;/p&gt;
&lt;p&gt;&lt;a href='http://net.tutsplus.com/tutorials/tools-and-tips/sublime-text-2-tips-and-tricks/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d2o0t5hpnwv4c1.cloudfront.net/1119_html5/html5-media-and-accessibility.jpg" alt="An In Depth Analysis of HTML5 Multimedia and Accessibility" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://net.tutsplus.com/tutorials/html-css-techniques/an-in-depth-overview-of-html5-multimedia-and-accessibility/'&gt;An In Depth Analysis of HTML5 Multimedia and Accessibility&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;In this tutorial, youll learn how HTML5 helps to provide you with several ways of presenting your media content to users. As a result, youll increase the availability of your media to users with different&lt;br /&gt;
needs and requirements, making it more accessible.&lt;/p&gt;
&lt;p&gt;&lt;a href='http://net.tutsplus.com/tutorials/html-css-techniques/an-in-depth-overview-of-html5-multimedia-and-accessibility/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d2o0t5hpnwv4c1.cloudfront.net/1129_api_wrapper_tdd/api-wrapper-for-dribbble.png" alt="Writing an API Wrapper in Ruby with TDD" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://net.tutsplus.com/tutorials/ruby/writing-an-api-wrapper-in-ruby-with-tdd/'&gt;Writing an API Wrapper in Ruby with TDD&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Sooner or later, all developers are required to interact with an API. The most difficult part is always related to reliably testing the code we write, and, as we want to make sure that everything works properly, we continuosly run code that queries the API itself. This process is slow and inefficient, as we can experience network issues and data inconsistencies (the API results may change). Let&amp;#8217;s review how we can avoid all of this effort with Ruby.&lt;/p&gt;
&lt;p&gt;&lt;a href='http://net.tutsplus.com/tutorials/ruby/writing-an-api-wrapper-in-ruby-with-tdd/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;hr /&gt;
&lt;h2&gt;Vectortuts+ — Illustrator Tutorials&lt;/h2&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://dsmy2muqb7t4m.cloudfront.net/tuts/000-2012/477-microscope/preview.jpg" alt="How to Illustrate a Microscope in Illustrator" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://vector.tutsplus.com/tutorials/illustration/illustrate-a-microscope/'&gt;How to Illustrate a Microscope in Illustrator&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;The microscopes is a symbol of our civilization. Throughout this tutorial on how to illustrate a vector microscope you&amp;#8217;ll take advantage of numerous Illustrator tools. You will learn how to use blends, art brushes and 3D rendering in Adobe Illustrator. Let&amp;#8217;s get started!&lt;/p&gt;
&lt;p&gt;&lt;a href='http://vector.tutsplus.com/tutorials/illustration/illustrate-a-microscope/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://dsmy2muqb7t4m.cloudfront.net/tuts/000-2012/471-gallery/preview.jpg" alt="Create a Picture Gallery in Illustrator" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://vector.tutsplus.com/tutorials/illustration/create-a-picture-gallery/'&gt;Create a Picture Gallery in Illustrator&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;This work is a common project created together with &lt;a href="http://vector.tutsplus.com/author/iaroslav-lazunov/" &gt;Iaroslav Lazunov&lt;/a&gt; and &lt;a href="http://vector.tutsplus.com/author/alexander-egupov/" &gt;Alexander Egupov&lt;/a&gt;. We have used 3D rendering, Blends, Opacity masks, making this three-dimensional stage with vanishing points. Learn every step in how to create this picture gallery work.&lt;/p&gt;
&lt;p&gt;&lt;a href='http://vector.tutsplus.com/tutorials/illustration/create-a-picture-gallery/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://dsmy2muqb7t4m.cloudfront.net/articles/2012/article-tutorials-typeface-font-design/preview.jpg" alt="13 Important Resources for Learning How to Design Typefaces and Full Fonts" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://vector.tutsplus.com/articles/web-roundups/how-to-design-typefaces-fonts/'&gt;Important Resources for Learning How to Design Typefaces and Full Fonts&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;If you&amp;#8217;re serious about creating a typeface design, then you&amp;#8217;ll need some solid resources to get started. Learn effective typeface design workflows, how to take an initial spark of an idea from sketch, through Illustrator, into Fontlab, and then work your creation into a complete and custom font design. Here are multiple tutorials that show you how to create fonts in Illustrator and Fontlab, and you can also dive into articles that describe the foundation of quality type design with ample inspirational examples.&lt;/p&gt;
&lt;p&gt;&lt;a href='http://vector.tutsplus.com/articles/web-roundups/how-to-design-typefaces-fonts/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;hr /&gt;
&lt;h2&gt;Webdesigntuts+ — Web Design Tutorials&lt;/h2&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d3pr5r64n04s3o.cloudfront.net/articles/062_pairing_fonts/preview.png" alt="A Beginner&amp;#8217;s Guide to Pairing Fonts" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://webdesign.tutsplus.com/articles/typography-articles/a-beginners-guide-to-pairing-fonts/'&gt;A Beginner&amp;#8217;s Guide to Pairing Fonts&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Pairing fonts can be a challenge. Selecting two or more fonts which work well is one thing &amp;#8211; selecting two which work &lt;em&gt;together&lt;/em&gt; to achieve your typographic aims may have you reaching for the aspirin. Let&amp;#8217;s see if we can alleviate any headaches. This guide will help you get started with font pairing for the web.&lt;/p&gt;
&lt;p&gt;&lt;a href='http://webdesign.tutsplus.com/articles/typography-articles/a-beginners-guide-to-pairing-fonts/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d3pr5r64n04s3o.cloudfront.net/tuts/235_banner_ads/preview.png" alt="Design a Series of Smart Banner Ads in Photoshop" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://webdesign.tutsplus.com/tutorials/visuals/design-a-series-of-smart-banner-ads-in-photoshop/'&gt;Design a Series of Smart Banner Ads in Photoshop&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;With the continuous growth of the Internet, online marketing has gotten bigger every year, and along with it, the advertising industry. One major factor in all this craziness is buying and selling ads. &lt;/p&gt;
&lt;p&gt;&lt;a href='http://webdesign.tutsplus.com/tutorials/visuals/design-a-series-of-smart-banner-ads-in-photoshop/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="https://d3pr5r64n04s3o.cloudfront.net/tuts/231_twitter_bootstrap_101/bootstrap.png" alt="Twitter Bootstrap 101: Introduction" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://webdesign.tutsplus.com/tutorials/complete-websites/twitter-bootstrap-101-introduction/'&gt;Twitter Bootstrap 101: Introduction&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Twitter&amp;#8217;s Bootstrap is an excellent set of carefully crafted user interface elements, layouts, and javascript tools, freely available to use in your next web design project. This video series aims to introduce you to Bootstrap; taking you all the way from downloading the resources, to building a complete Bootstrap-based website.&lt;/p&gt;
&lt;p&gt;&lt;a href='http://webdesign.tutsplus.com/tutorials/complete-websites/twitter-bootstrap-101-introduction/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;hr /&gt;
&lt;h2&gt;Phototuts+ — Photography Tutorials&lt;/h2&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d2f29brjr0xbt3.cloudfront.net/805_hdrtakeleave/preview.jpg" alt="HDR: Love it or Leave It?" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://photo.tutsplus.com/articles/post-processing-articles/hdr-love-it-or-leave-it/'&gt;HDR: Love it or Leave It?&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;There are few techniques in the photography world that divide our community as much as HDR. High dynamic range images, or HDR images, are a special type of composite image that combines several images at different exposure settings in order to create an image with increased dynamic range. The look provided by HDR is loved by many, and disliked by perhaps just as many. In today&amp;#8217;s article, we&amp;#8217;re going to take a better look at what HDR is, and get some opinions from photographers using HDR.&lt;span id="more-8505"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href='http://photo.tutsplus.com/articles/post-processing-articles/hdr-love-it-or-leave-it/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d2f29brjr0xbt3.cloudfront.net/807_motorsportRU/preview.jpg" alt="50 Inspiring Images of Cars and Motorcycles" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://photo.tutsplus.com/articles/inspiration/50-inspiring-images-of-cars-and-motorcycles/'&gt;Inspiring Images of Cars and Motorcycles&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Cars and motorbikes have been around for 100 years. Throughout the century, they have looked beautiful, satisfied our need for speed and become a symbol for thrill seeking. Today, we&amp;#8217;ll look at photos ranging from brand new Ferrari&amp;#8217;s to classic muscle cars.&lt;span id="more-8519"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href='http://photo.tutsplus.com/articles/inspiration/50-inspiring-images-of-cars-and-motorcycles/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d2f29brjr0xbt3.cloudfront.net/822_gimpQT/preview.jpg" alt="Quick Tip: GIMP Portable &amp;#8211; Take Your Editing Software With You" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://photo.tutsplus.com/articles/post-processing-articles/quick-tip-gimp-portable-take-your-editing-software-with-you/'&gt;Quick Tip: GIMP Portable &amp;#8211; Take Your Editing Software With You&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;While a number of smartphones now offer photo editing basics (and a plethora of apps to expand things even more), the portability of a solid photo editing program has been hard to come by. Photoshop is a monster in regards to space requirements and its ability to work on any system where it is not expressively installed. Picasa can be fairly &amp;#8216;lightweight&amp;#8217; but lacks many of the more advanced photo editing tools. So what about GIMP?&lt;span id="more-8627"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href='http://photo.tutsplus.com/articles/post-processing-articles/quick-tip-gimp-portable-take-your-editing-software-with-you/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;hr /&gt;
&lt;h2&gt;Cgtuts+ — Computer Graphics Tutorials&lt;/h2&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d2d04grx5ahzvh.cloudfront.net/336_Blender_TRex_Modeling/Thumb.png" alt="Modeling, UVmapping And Texturing A Low Poly T-Rex In Blender, Part 1" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://cg.tutsplus.com/tutorials/blender/modeling-uvmapping-and-texturing-a-low-poly-t-rex-in-blender-part-1/'&gt;Modeling, UVmapping And Texturing A Low Poly T-Rex In Blender, Part 1&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;In the first tutorial of 2012 you’ll learn how to create an awesome low-poly dinosaur using Blender and Gimp. In today’s post artist Karan Shah will walk you through the entire modeling process step by step, and show you how to create an optimized model suitable for use in any game engine.&lt;/p&gt;
&lt;p&gt;&lt;a href='http://cg.tutsplus.com/tutorials/blender/modeling-uvmapping-and-texturing-a-low-poly-t-rex-in-blender-part-1/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d2d04grx5ahzvh.cloudfront.net/337_Maya_Fluids_Explosion/Thumb.jpg" alt="Create A Realistic Explosion In Maya Using Maya Fluids" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://cg.tutsplus.com/tutorials/autodesk-maya/create-a-realistic-explosion-in-maya-using-maya-fluids/'&gt;Create A Realistic Explosion In Maya Using Maya Fluids&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Today you’ll learn to animate and shade fluids, understand all of the major attributes, learn how adding fields will allow you to gain better control over your simulation, and how to light and render the final animation.&lt;/p&gt;
&lt;p&gt;&lt;a href='http://cg.tutsplus.com/tutorials/autodesk-maya/create-a-realistic-explosion-in-maya-using-maya-fluids/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d2d04grx5ahzvh.cloudfront.net/339_UDK_Speedtree_Part_1/Thumb.jpg" alt="SpeedTree To UDK: The Complete Workflow, Part 1 Creating The Tree" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://cg.tutsplus.com/tutorials/game-dev/speedtree-to-udk-the-complete-workflow-part-1/'&gt;SpeedTree To UDK: The Complete Workflow, Part 1 Creating The Tree&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Due to the shear number of polygons often required to make believable 3D trees, creating realistic ones for use &amp;#8220;in-game&amp;#8221; can be a challenging, time consuming task. SpeedTree from IDV aims to change all that with it&amp;#8217;s intuitive UI, ease of use and powerful toolset. Making believable trees and plants has literally never been easier!&lt;/p&gt;
&lt;p&gt;&lt;a href='http://cg.tutsplus.com/tutorials/game-dev/speedtree-to-udk-the-complete-workflow-part-1/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;hr /&gt;
&lt;h2&gt;Aetuts+ — After Effects Tutorials&lt;/h2&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d3gphd0pfuxn95.cloudfront.net/694_dominoes/dominoes_thumbnail.jpg" alt="&amp;#8220;Dominoes&amp;#8221; CameraTracker and Cinema 4d Case Study &amp;#8211; Day 1" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://ae.tutsplus.com/tutorials/workflow/dominoes-cameratracker-and-cinema-4d-case-study-day-1/'&gt;Dominoes&amp;#8221; CameraTracker and Cinema 4d Case Study &amp;#8211; Day 1&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;In this tutorial we&amp;#8217;re going to go over the principle functionality of &lt;a href="http://www.thefoundry.co.uk/products/cameratracker/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','www.thefoundry.co.uk']);"&gt;CameraTracker&lt;/a&gt; from The Foundry, learning basic workflow, optimizing results, aligning the ground plane and exporting this data from After Effects to &lt;a href="http://www.maxon.net/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','www.maxon.net']);" rel="external"&gt;Cinema 4d&lt;/a&gt;.&lt;span id="more-18522"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href='http://ae.tutsplus.com/tutorials/workflow/dominoes-cameratracker-and-cinema-4d-case-study-day-1/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://tutsplus.s3.amazonaws.com/tutspremium/after-effects/59_flame_react/Flame_Reactant_Thumbnail.jpg" alt="Make An Amazing Motion Reactant Flame &amp;#8211; Tuts+ Premium" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://ae.tutsplus.com/tutorials/vfx/make-an-amazing-motion-reactant-flame-tutsplus-premium/'&gt;Make An Amazing Motion Reactant Flame &amp;#8211; Tuts+ Premium&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Using just a few video elements of torch flames, we composite a burning hand by using a series of null objects and expressions to drive a &lt;strong&gt;time lagged displacement effect&lt;/strong&gt; to simulate fire burning from a moving source. We use the Puppet tool for the distortion and throw on some tracked lighting effects and a displacement map for the Heat. This principle can be used to &lt;strong&gt;add realistic, fluid motion to any tracked object&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href='http://ae.tutsplus.com/tutorials/vfx/make-an-amazing-motion-reactant-flame-tutsplus-premium/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d3gphd0pfuxn95.cloudfront.net/misc/freelancer.jpg" alt="10 Key Tips To Becoming A Successful Video Freelancer" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://ae.tutsplus.com/articles/in-depth/10-key-tips-to-becoming-a-successful-video-freelancer/'&gt;Key Tips To Becoming A Successful Video Freelancer&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Youve watched thousands of tutorials. Youve put in countless hours and spent many late nights working on personal projects. Youve finally come to the conclusion that this may just be something you would like to do for a career. It can seem a little intimidating at first, because how are you going to convince someone to pay you to do this? Up until now youve been your only client. How do you get more?  Im going to share my insight and experiences on how to successfully launch your freelance career this year!&lt;/p&gt;
&lt;p&gt;&lt;a href='http://ae.tutsplus.com/articles/in-depth/10-key-tips-to-becoming-a-successful-video-freelancer/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;hr /&gt;
&lt;h2&gt;Audiotuts+ — Audio &amp;#038; Production Tutorials&lt;/h2&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d3vvl31cy8gagb.cloudfront.net/713_8free/Preview Image.jpg" alt="8 Free Professional Quality Audio Unit Plug-ins for Mac" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://audio.tutsplus.com/articles/general/8-free-professional-quality-audio-unit-plug-ins-for-mac/'&gt;Free Professional Quality Audio Unit Plug-ins for Mac&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Lets face it, software is expensive. While there are hundreds of free plug-ins available online, more often than not two problems will arise: One, most of them are for PCs leaving us Mac users feeling left out. Two, most of them are vary poor quality.&lt;/p&gt;
&lt;p&gt;While I do agree with the saying, &amp;#8220;The tools are only as good as the artist,&amp;#8221; I also believe the opposite is true; that at some point the artist can only be as good as his tools are.&lt;/p&gt;
&lt;p&gt;&lt;a href='http://audio.tutsplus.com/articles/general/8-free-professional-quality-audio-unit-plug-ins-for-mac/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d3vvl31cy8gagb.cloudfront.net/qt_168_drums4/Thumbnail.jpg" alt="Quick Tip: Drum Processing Part 4: Tips and Tricks" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://audio.tutsplus.com/tutorials/production/quick-tip-drum-processing-part-4-tips-and-tricks/'&gt;Quick Tip: Drum Processing Part 4: Tips and Tricks&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;This short series of quick tips is designed to give you a good overview of the audio processing techniques involved in creating a professional sounding drum beat for use in house, electro and breaks in Cubase. In this final part we will look at a few ways to add even more life to your drums.&lt;br /&gt;
&lt;span id="more-13319"&gt;&lt;/span&gt;&lt;br /&gt;
Here is a sample of the type of beat you could expect to end up with at the end of this series of tips:&lt;/p&gt;
&lt;p&gt;&lt;a href='http://audio.tutsplus.com/tutorials/production/quick-tip-drum-processing-part-4-tips-and-tricks/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d3vvl31cy8gagb.cloudfront.net/qt_164_math/preview.jpg" alt="Quick Tip: Use the Doubling Technique for Quick Drums" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://audio.tutsplus.com/tutorials/production/quick-tip-use-the-doubling-technique-for-quick-drums/'&gt;Quick Tip: Use the Doubling Technique for Quick Drums&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;It&amp;#8217;s 3:30 in the afternoon when your phone rings. The head of a music library is calling and she needs your help. They have a commercial for an A-list client that needs music, and they want you to submit an entry. You&amp;#8217;ll get $10,000 if you land the gig.&lt;/p&gt;
&lt;p&gt;&lt;a href='http://audio.tutsplus.com/tutorials/production/quick-tip-use-the-doubling-technique-for-quick-drums/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;hr /&gt;
&lt;h2&gt;Activetuts+ — Flash, Flex &amp;#038; ActionScript Tutorials&lt;/h2&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/394_microphoneGameCode/preview.jpg" alt="Create a Microphone-Controlled Flash Game: Code" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://active.tutsplus.com/tutorials/games/create-a-microphone-controlled-flash-game-code/'&gt;Create a Microphone-Controlled Flash Game: Code&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;In this mini-series, we&amp;#8217;re creating a spaceship game where the main control is via the microphone: shout louder to make the ship fly higher. &lt;a href="http://active.tutsplus.com/tutorials/games/create-a-microphone-controlled-flash-game-design/" &gt;So far&lt;/a&gt;, we&amp;#8217;ve created all the required graphical elements for the game. Now, it&amp;#8217;s time to work on our code. We&amp;#8217;ve got a lot to do, so let&amp;#8217;s get started!&lt;span id="more-10562"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href='http://active.tutsplus.com/tutorials/games/create-a-microphone-controlled-flash-game-code/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/articles/084_whyBotherWithjQuery/why_bother_with_jquery.png" alt="Why Bother With jQuery? A Guide for (Former) Flash Developers" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://active.tutsplus.com/articles/explanatory/why-bother-with-jquery-a-guide-for-former-flash-developers/'&gt;Why Bother With jQuery? A Guide for (Former) Flash Developers&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;If you, like many Flash developers, are looking into using HTML5 for your web apps, you&amp;#8217;ll almost certainly have come across jQuery. It&amp;#8217;s a very popular JavaScript library, used by &lt;a href="http://trends.builtwith.com/javascript/JQuery" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','trends.builtwith.com']);" rel="external"&gt;a large percentage&lt;/a&gt; of the most visited websites &amp;#8211; but what&amp;#8217;s all the fuss about, and should you use it?&lt;span id="more-10723"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href='http://active.tutsplus.com/articles/explanatory/why-bother-with-jquery-a-guide-for-former-flash-developers/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/398_gamepadAPIIntro/gamepadAPI-preview.jpg" alt="An Introduction to the HTML5 Gamepad API" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://active.tutsplus.com/tutorials/games/an-introduction-to-the-html5-gamepad-api/'&gt;An Introduction to the HTML5 Gamepad API&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;As HTML games begin to gradually increase in popularity, vendors are starting to introduce some exciting new APIs to make gaming that little bit sweeter for both us developers and our end players. One of these is the GamepadAPI, which allows you to connect your good old console gamepad into your computer and use it for browser based games, plug and play style. Let&amp;#8217;s dive in!&lt;span id="more-10686"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href='http://active.tutsplus.com/tutorials/games/an-introduction-to-the-html5-gamepad-api/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;hr /&gt;
&lt;h2&gt;Wptuts+ — WordPress Tutorials&lt;/h2&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://wptutsplus.s3.amazonaws.com/159_RiseHTML5/html5.jpg" alt="The Rise of HTML5 in WordPress" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://wp.tutsplus.com/articles/the-rise-of-html5-in-wordpress/'&gt;The Rise of HTML5 in WordPress&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;2011 was a big year for the advancement of HTML5 in the web development community. It became pretty widely adopted, especially for the mobile web. There have been major projects that help developers use HTML5, like Paul Irish&amp;#8217;s &lt;a href="http://html5boilerplate.com/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','html5boilerplate.com']);"&gt;HTML5 Boilerplate&lt;/a&gt; (technically 2010, but popularized in 2011) and books galore!&lt;/p&gt;
&lt;p&gt;&lt;a href='http://wp.tutsplus.com/articles/the-rise-of-html5-in-wordpress/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://wptutsplus.s3.amazonaws.com/131_MetaBoxPt1/metabox_0.jpg" alt="Reusable Custom Meta Boxes Part 3: Extra Fields" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-3-extra-fields/'&gt;Reusable Custom Meta Boxes Part 3: Extra Fields&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;In &lt;a href="http://wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-1-intro-and-basic-fields/" &gt;Part 1&lt;/a&gt; and &lt;a href="http://wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-2-advanced-fields/" &gt;Part 2&lt;/a&gt; of our custom meta box template tutorial series, we learned how to create a field array to loop through and create a custom meta box with your standard fields. Now let&amp;#8217;s throw in a bit of JavaScript for some fancy, but highly useful fields.&lt;/p&gt;
&lt;p&gt;&lt;a href='http://wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-3-extra-fields/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://wptutsplus.s3.amazonaws.com/167_ySlowTut/img/uwo.png" alt="The Ultimate Quickstart Guide to Speeding Up Your WordPress Site" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://wp.tutsplus.com/tutorials/the-ultimate-quickstart-guide-to-speeding-up-your-wordpress-site/'&gt;The Ultimate Quickstart Guide to Speeding Up Your WordPress Site&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Give your site a boost! Implement crucial optimization techniques that will improve not only your &lt;strong&gt;&lt;a href="http://developer.yahoo.com/yslow/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','developer.yahoo.com']);"&gt;ySlow &lt;/a&gt;&lt;/strong&gt;score, but your Google rank too. In this tutorial we will cover all aspects of W3 caching, ySlow, Google page speed, CSS sprites &amp;#038; htaccess rules, to achieve a high ySlow score like i have done on &lt;a href="http://imattic.com/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','imattic.com']);"&gt;my blog.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href='http://wp.tutsplus.com/tutorials/the-ultimate-quickstart-guide-to-speeding-up-your-wordpress-site/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;hr /&gt;
&lt;h2&gt;Mobiletuts+ — Mobile Development Tutorials&lt;/h2&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d339vfjsz5zott.cloudfront.net/iOS-SDK_Creating-A-Carousel/carousel.jpg" alt="iOS SDK: Creating an Awesome Carousel" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-creating-an-awesome-carousel/'&gt;iOS SDK: Creating an Awesome Carousel&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Engage your users with stunning carousels.  We&amp;#8217;ll look at how easy and clean it can be to implement scrollable, interactive carousels in your iOS applications.  With high configurability, you can have 3D, flat, rotating, and endless scrolling arrays for data, images, or buttons.&lt;br /&gt;
&lt;span id="more-9302"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href='http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-creating-an-awesome-carousel/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d339vfjsz5zott.cloudfront.net/PhoneGap-From-Scratch/phonegap.jpg" alt="PhoneGap From Scratch: Introduction" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://mobile.tutsplus.com/tutorials/phonegap/phonegap-from-scratch/'&gt;PhoneGap From Scratch: Introduction&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Want to learn how to use PhoneGap, but don&amp;#8217;t know where to get started? Join us as we put together &amp;#8220;Sculder&amp;#8221;, not only a tribute to an excellent science fiction TV series, but a fully-fledged native mobile application for the believer in you!&lt;/p&gt;
&lt;p&gt;&lt;a href='http://mobile.tutsplus.com/tutorials/phonegap/phonegap-from-scratch/'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li class='clear'&gt;
&lt;div&gt;
		&lt;img src="http://d339vfjsz5zott.cloudfront.net/Mobile-Flash-Is-Far-From-Dead/mobile-flash.png" alt="Mobile Flash is Far From Dead: Setting the Record Straight" width="200" height="200" /&gt;
	&lt;/div&gt;
&lt;h4&gt;&lt;a href='http://mobile.tutsplus.com/?p=9436'&gt;Mobile Flash is Far From Dead: Setting the Record Straight&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;In light of recent announcements from Adobe, there has been a lot of confusion over the state of the Flash Platform &amp;#8211; specifically in regard to Flash content on mobile devices. This article seeks to clarify many of the misconceptions that exist by addressing the main points of confusion around these announcements regardless of the initial, monumental, and absolutely unbelievable blunders from failed public (and private) relations messaging and general marketing surrounding these announcements.&lt;span id="more-9436"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href='http://mobile.tutsplus.com/?p=9436'&gt;Visit Article&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/RyGXP5dIV0x2e053OaW828tpros/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RyGXP5dIV0x2e053OaW828tpros/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/RyGXP5dIV0x2e053OaW828tpros/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RyGXP5dIV0x2e053OaW828tpros/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=YCpxT3ZBypM:DtifwcT4qIg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=YCpxT3ZBypM:DtifwcT4qIg:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=YCpxT3ZBypM:DtifwcT4qIg:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=YCpxT3ZBypM:DtifwcT4qIg:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=YCpxT3ZBypM:DtifwcT4qIg:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=YCpxT3ZBypM:DtifwcT4qIg:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=YCpxT3ZBypM:DtifwcT4qIg:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=YCpxT3ZBypM:DtifwcT4qIg:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=YCpxT3ZBypM:DtifwcT4qIg:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=YCpxT3ZBypM:DtifwcT4qIg:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Flashtuts/~4/YCpxT3ZBypM" height="1" width="1"/&gt;</description>
		<wfw:commentRss>http://active.tutsplus.com/articles/news/best-of-tuts-in-january-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://active.tutsplus.com/articles/news/best-of-tuts-in-january-2012/</feedburner:origLink></item>
		<item>
		<title>Free Flash Debugger: Commando (With Premium Source Files)</title>
		<link>http://feedproxy.google.com/~r/Flashtuts/~3/QBthAYmWrww/</link>
		<comments>http://active.tutsplus.com/tutorials/workflow/free-flash-debugger-commando-with-premium-source-files/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 08:00:55 +0000</pubDate>
		<dc:creator>Aditya Keerthi</dc:creator>
				<category><![CDATA[Exclusive]]></category>
		<category><![CDATA[Workflow]]></category>
		<category><![CDATA[commando]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[freebie]]></category>
		<category><![CDATA[Premium]]></category>
		<category><![CDATA[workflow]]></category>
		<guid isPermaLink="false">http://active.tutsplus.com/?p=10775</guid>
		<description>&lt;p&gt;Commando is a Flash debugger that lets you change variables at runtime and run your own custom commands. It will allow you to try out whatever tweaks you want, without the hassle of changing your code and recompiling every time. This debugger also comes with its own memory monitor, and an output panel that is similar to the output dialog in the Flash IDE.&lt;/p&gt;
&lt;p&gt;&lt;span id="more-10775"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;See Commando in Action&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
&lt;object width="600" height="343" data="http://d2fhka9tf2vaj2.cloudfront.net/freebies/014_commando/Commando.swf" type="application/x-shockwave-flash"&gt;&lt;param name="src" value="http://d2fhka9tf2vaj2.cloudfront.net/freebies/014_commando/Commando.swf" /&gt;&lt;/object&gt;
&lt;/div&gt;
&lt;hr/&gt;
&lt;h2&gt;Why Use Commando?&lt;/h2&gt;
&lt;p&gt;Using Commando you can change your code at runtime. Let&amp;#8217;s pretend you are making a platformer game. You have a &lt;code&gt;jumpPower&lt;/code&gt; variable, but when testing your game you feel that the player can&amp;#8217;t jump high enough. So instead of going back and changing your code, you can just type &lt;code&gt;set jumpPower(25)&lt;/code&gt; in Commando and you can try out the new value. &lt;/p&gt;
&lt;p&gt;Of course, this is just a simple demonstration; Commando can be extended even more. Just continue reading&amp;#8230;&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;Configuration&lt;/h2&gt;
&lt;p&gt;First, download the ZIP file included with this article. Then, add the SWC file to your project&amp;#8217;s library path.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/freebies/014_commando/swc_installation.jpg" alt="The Library Path Dialog" /&gt;&lt;/div&gt;
&lt;p&gt;Once you have added the SWC to your project&amp;#8217;s library path, all you need are three lines of code to add an instance of Commando on the stage:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
import com.pxlcoder.debug.Commando;

var commando:Commando = new Commando(flash.ui.Keyboard.ENTER, this);
addChild(commando);
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Now press CTRL+ENTER (CMD+ENTER on a Mac), and you will see Commando up and running in your Flash project!&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;Explore&lt;/h2&gt;
&lt;p&gt;Commando comes with eight built-in functions. In this section I will explain what they are and how to use them.&lt;/p&gt;
&lt;h3&gt;Math&lt;/h3&gt;
&lt;p&gt;Using the Math function you can do addition, subtraction, multiplication and division between two numbers. The Math function can also calculate the square root of a number. For example, type &lt;code&gt;math 1+1&lt;/code&gt; or &lt;code&gt;math sqrt(144)&lt;/code&gt; in the Commando dialog. The answer will show up in the output dialog.&lt;/p&gt;
&lt;h3&gt;Hide&lt;/h3&gt;
&lt;p&gt;You can use the Hide function to hide objects. You can type &lt;code&gt;hide monitor&lt;/code&gt; or &lt;code&gt;hide output&lt;/code&gt; to hide the two panels at the bottom. You can also use the Hide function with movieclips or buttons by simply typing &lt;code&gt;hide &lt;em&gt;myInstanceName&lt;/em&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;View&lt;/h3&gt;
&lt;p&gt;You can use the View function to view hidden objects. You can type &lt;code&gt;view monitor&lt;/code&gt; or &lt;code&gt;view output&lt;/code&gt; to show the two panels at the bottom. You can also use the View function with movieclips or buttons by simply typing &lt;code&gt;view &lt;em&gt;myInstanceName&lt;/em&gt;&lt;/code&gt;. If any of your objects have their &lt;code&gt;visible&lt;/code&gt; property set to &lt;code&gt;false&lt;/code&gt;, typing &lt;code&gt;view &lt;em&gt;myInstanceName&lt;/em&gt;&lt;/code&gt; will set it to true.&lt;/p&gt;
&lt;h3&gt;Set&lt;/h3&gt;
&lt;p&gt;Using the Set function you can set values of your variables or you can set properties of your objects. To use the Set function on variables type &lt;code&gt;set &lt;em&gt;myVariable&lt;/em&gt;(&lt;em&gt;myValue&lt;/em&gt;)&lt;/code&gt;. To use the Set function on objects, type &lt;code&gt;set &lt;em&gt;myInstanceName&lt;/em&gt;(&lt;em&gt;myPropertyName&lt;/em&gt;,&lt;em&gt;myValue&lt;/em&gt;)&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Get&lt;/h3&gt;
&lt;p&gt;Using the Get function you can get the values of your variables and properties. To use the Get function type &lt;code&gt;get &lt;em&gt;myVariable&lt;/em&gt;&lt;/code&gt;. You can also get properties by typing &lt;code&gt;get &lt;em&gt;myInstanceName&lt;/em&gt;.&lt;em&gt;myPropertyName&lt;/em&gt;&lt;/code&gt;.The values will show up in the output dialog.&lt;/p&gt;
&lt;h3&gt;Probe&lt;/h3&gt;
&lt;p&gt;Using the Rrobe function you can get the probe all of the properties of an object. To use the Probe function type: &lt;code&gt;probe &lt;em&gt;myObjectInstanceName&lt;/em&gt;&lt;/code&gt;. The properties will be traced in the Flash IDE, rather than in the Commando output dialog.&lt;/p&gt;
&lt;h3&gt;Remove&lt;/h3&gt;
&lt;p&gt;You can use the Remove function to remove objects from the stage. To use the Remove function type &lt;code&gt;remove &lt;em&gt;myInstanceName&lt;/em&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Add&lt;/h3&gt;
&lt;p&gt;You can use the Add function to add objects back on to the stage. To use the Add function type &lt;code&gt;add &lt;em&gt;myInstanceName&lt;/em&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Commando&amp;#8217;s built-in functions each evaluate a single string, so after you type your function name and press space, make sure to type your arguments without any spaces. Instead, type your arguments as one continuous word, with commas if necessary.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;Extend&lt;/h2&gt;
&lt;p&gt;While Commando has many great built-in functions, you may want something more. To solve this problem, Commando comes with a function to add your own custom commands.&lt;/p&gt;
&lt;p&gt;Here is a quick code example of how you can create your own custom commands:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
import com.pxlcoder.debug.Commando;

var commando:Commando = new Commando(flash.ui.Keyboard.ENTER, this);
addChild(commando); 

commando.addCommand(&amp;quot;output&amp;quot;, outputFunction); //Sets the command keyword to &amp;quot;output&amp;quot; and calls the outputFunction below

public function outputFunction(s:String):void {
     commando.output(s); //A call to Commando's built-in output dialog
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Now press CTRL+ENTER (CMD+ENTER on a Mac), to run your code. In the Commando dialog, type &lt;code&gt;output hello&lt;/code&gt;, and press Enter. The output dialog will now say hello!&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/freebies/014_commando/custom_function_example.jpg" alt="Commando says hello!" /&gt;&lt;/div&gt;
&lt;p&gt;You can also remove commands from Commando by using the &lt;code&gt;removeCommand()&lt;/code&gt; function.&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; title: ; notranslate"&gt;
import com.pxlcoder.debug.Commando;

var commando:Commando = new Commando(flash.ui.Keyboard.ENTER, this);
addChild(commando); 

commando.removeCommand(&amp;quot;output&amp;quot;);
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Recap:&lt;/strong&gt; Commando has three functions that you can access; &lt;code&gt;addCommand()&lt;/code&gt;, &lt;code&gt;output()&lt;/code&gt; and &lt;code&gt;removeCommand()&lt;/code&gt;.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;At the end of the day, debugging is the most important part in the development process. Commando has everything you could ever ask for in a debugger. You can use it for anything and everything.&lt;/p&gt;
&lt;p&gt;If you&amp;#8217;re a Tuts+ Premium member, you can download the source files for Commando &amp;#8211; just log in and head to the &lt;a href="http://tutsplus.com/source-file/commando-a-flash-debugger/"&gt;Source File page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Any questions, comments or concerns? Feel free to get in touch in the comments.&lt;/p&gt;
&lt;p&gt;Take control of your Flash projects!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-Gx7E7fFygRwFqhf3fPRSoCAf2Y/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-Gx7E7fFygRwFqhf3fPRSoCAf2Y/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-Gx7E7fFygRwFqhf3fPRSoCAf2Y/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-Gx7E7fFygRwFqhf3fPRSoCAf2Y/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=QBthAYmWrww:29Fq4aldbOQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=QBthAYmWrww:29Fq4aldbOQ:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=QBthAYmWrww:29Fq4aldbOQ:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=QBthAYmWrww:29Fq4aldbOQ:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=QBthAYmWrww:29Fq4aldbOQ:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=QBthAYmWrww:29Fq4aldbOQ:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=QBthAYmWrww:29Fq4aldbOQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=QBthAYmWrww:29Fq4aldbOQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=QBthAYmWrww:29Fq4aldbOQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=QBthAYmWrww:29Fq4aldbOQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Flashtuts/~4/QBthAYmWrww" height="1" width="1"/&gt;</description>
		<wfw:commentRss>http://active.tutsplus.com/tutorials/workflow/free-flash-debugger-commando-with-premium-source-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://active.tutsplus.com/tutorials/workflow/free-flash-debugger-commando-with-premium-source-files/</feedburner:origLink></item>
		<item>
		<title>Create an HTML5 Canvas Tile Swapping Puzzle</title>
		<link>http://feedproxy.google.com/~r/Flashtuts/~3/hgS1BfLd7IM/</link>
		<comments>http://active.tutsplus.com/tutorials/games/create-an-html5-canvas-tile-swapping-puzzle/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 07:00:39 +0000</pubDate>
		<dc:creator>Brad Manderscheid</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[puzzle]]></category>
		<guid isPermaLink="false">http://active.tutsplus.com/?p=10747</guid>
		<description>&lt;p&gt;In this tutorial we will be working with the HTML5 canvas and Javascript to create a dynamic tile swapping game. The result will be a puzzle that works with any given image, and has flexible difficulty levels that are easily adjusted. &lt;/p&gt;
&lt;p&gt;&lt;span id="more-10747"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;The Complete HTML5 Canvas Puzzle&lt;/h2&gt;
&lt;p&gt;Here is a quick shot of the puzzle we will be building:&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;a href="http://d2fhka9tf2vaj2.cloudfront.net/tuts/403_html5TileSwapPuzzle/demo/puzzle.html"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/403_html5TileSwapPuzzle/html5_canvas_puzzle.jpg" alt="Final HTML5 Puzzle" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;Click to play&lt;/div&gt;
&lt;p&gt;A couple of notes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cross-browser compatibility:&lt;/strong&gt; This puzzle was tested and works in all versions of Safari, Firefox, and Chrome that support the &lt;code&gt;canvas&lt;/code&gt; element.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mobile:&lt;/strong&gt; The code provide here works in the above-mentioned desktop browser and is not optimised for mobile. The puzzle will load and render just fine, but because of the touch and drag behaviors in mobile browsers, optimization is required for it to function correctly.  Optimizing this puzzle for mobile will be covered in a future tutorial. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Adjustable Difficulty:&lt;/strong&gt; The code contains a constant, &lt;code&gt;PUZZLE_DIFFICULTY&lt;/code&gt;, that determines the number of pieces. In the demo above, this is set to &lt;code&gt;4&lt;/code&gt;, giving a 4&amp;#215;4 puzzle. We can easily change this &amp;#8211; for example, &lt;a href="http://d2fhka9tf2vaj2.cloudfront.net/tuts/403_html5TileSwapPuzzle/demo/puzzle_hard.html"&gt;this version&lt;/a&gt; has a &lt;code&gt;PUZZLE_DIFFICULTY&lt;/code&gt; of &lt;code&gt;10&lt;/code&gt;.
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2&gt;Getting Started&lt;/h2&gt;
&lt;p&gt;To get started, create a directory for the project.  Place an image in the directory that you want to use as your puzzle.  Any web friendly image will do, and it can be any size your heart desires &amp;#8211; just make sure it fits within the fold of your browser&amp;#8217;s window.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 1:&lt;/span&gt; Creating the HTML Template&lt;/h2&gt;
&lt;p&gt;Open a new file using your favorite text editor and save it inside your project directory, next to your image. Next, fill out this basic &lt;code&gt;HTML&lt;/code&gt; template.&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: xml; first-line: 1; title: ; notranslate"&gt;
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;HTML5 Puzzle&amp;lt;/title&amp;gt;
    &amp;lt;script&amp;gt;

    &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body onload=&amp;quot;init();&amp;quot;&amp;gt;
    &amp;lt;canvas id=&amp;quot;canvas&amp;quot;&amp;gt;&amp;lt;/canvas&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;All we need to do here is create a standard &lt;code&gt;HTML5&lt;/code&gt; template containing one &lt;code&gt;canvas&lt;/code&gt; tag with the &lt;code&gt;id&lt;/code&gt; of “canvas”.  We’ll write an &lt;code&gt;onload&lt;/code&gt; listener in the &lt;code&gt;body&lt;/code&gt; tag which will call our &lt;code&gt;init()&lt;/code&gt; function when fired.&lt;/p&gt;
&lt;p&gt;Now start by placing your cursor inside the &lt;code&gt;script&lt;/code&gt; tag.  From here on out it&amp;#8217;s &lt;strong&gt;all javascript.&lt;/strong&gt; With the exception of the initial variables, I&amp;#8217;ll be organising the sections by function.  First showing you the code and then explaining the logic.&lt;/p&gt;
&lt;p&gt;Ready?  Let&amp;#8217;s get right to it!&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 2:&lt;/span&gt; Setting Up Our Variables&lt;/h2&gt;
&lt;p&gt;Let’s set up our variables and take a look at each one.&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 7; title: ; notranslate"&gt;
const PUZZLE_DIFFICULTY = 4;
const PUZZLE_HOVER_TINT = '#009900';

var _canvas;
var _stage;

var _img;
var _pieces;
var _puzzleWidth;
var _puzzleHeight;
var _pieceWidth;
var _pieceHeight;
var _currentPiece;
var _currentDropPiece;

var _mouse;
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;First we have a couple of constants: &lt;code&gt;PUZZLE_DIFFICULTY&lt;/code&gt; and &lt;code&gt;PUZZLE_HOVER_TINT&lt;/code&gt;.  The &lt;code&gt;PUZZLE_DIFFICULTY&lt;/code&gt; constant holds the number of pieces in our puzzle.  In this application, the rows and columns always match, so by setting &lt;code&gt;PUZZLE_DIFFICULTY&lt;/code&gt; to &lt;code&gt;4&lt;/code&gt;, we get 16 puzzle pieces in total.  Increasing this increases the difficulty of the puzzle.&lt;/p&gt;
&lt;p&gt;Next is a series of variables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;_canvas&lt;/code&gt; and &lt;code&gt;_stage&lt;/code&gt; will hold a reference to the canvas and to its drawing context, respectively.  We do this so we don’t have to write out the entire query each time we use them.  And we’ll be using them a lot!&lt;/li&gt;
&lt;li&gt;&lt;code&gt;_img&lt;/code&gt; will be a reference to the loaded image, which we will be copying pixels from throughout the application.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;_puzzleWidth&lt;/code&gt;, &lt;code&gt;_puzzleHeight&lt;/code&gt;, &lt;code&gt;_pieceWidth&lt;/code&gt;, and &lt;code&gt;_pieceHeight&lt;/code&gt; will be used to store the dimensions of both the entire puzzle and each individual puzzle piece.  We set these once to prevent calculating them over and over again each time we need them.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;_currentPiece&lt;/code&gt; holds a reference to the piece currently being dragged.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;_currentDropPiece&lt;/code&gt; holds a reference to the piece currently in position to be dropped on. (In the demo, this piece is highlighted green.)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;_mouse&lt;/code&gt; is a reference that will hold the mouse&amp;#8217;s current &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; position.  This gets updated when the puzzle is clicked to determine which piece is touched, and when a piece is being dragged to determine what piece it&amp;#8217;s hovering over.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now, on to our functions.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 3:&lt;/span&gt; The &lt;code&gt;init()&lt;/code&gt; Function&lt;/h2&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 24; title: ; notranslate"&gt;
function init(){
    _img = new Image();
    _img.addEventListener('load',onImage,false);
    _img.src = &amp;quot;mke.jpg&amp;quot;;
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;The first thing we want to do in our application is to load the image for the puzzle.  The image object is first instantiated and set to our &lt;code&gt;_img&lt;/code&gt; variable.  Next, we listen for the &lt;code&gt;load&lt;/code&gt; event which will then fire our &lt;code&gt;onImage()&lt;/code&gt; function when the image has finished loading.  Lastly we set the source of the image, which triggers the load.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 4:&lt;/span&gt; The &lt;code&gt;onImage()&lt;/code&gt; Function&lt;/h2&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 29; title: ; notranslate"&gt;
function onImage(e){
    _pieceWidth = Math.floor(_img.width / PUZZLE_DIFFICULTY)
    _pieceHeight = Math.floor(_img.height / PUZZLE_DIFFICULTY)
    _puzzleWidth = _pieceWidth * PUZZLE_DIFFICULTY;
    _puzzleHeight = _pieceHeight * PUZZLE_DIFFICULTY;
    setCanvas();
    initPuzzle();
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Now that the image is successfully loaded, we can set the majority of the variables declared earlier.  We do this here because we now have information about the image and can set our values appropriately.&lt;/p&gt;
&lt;p&gt;The first thing we do is calculate the size of each puzzle piece.  We do this by dividing the &lt;code&gt;PUZZLE_DIFFICULTY&lt;/code&gt; value by the width and height of the loaded image.  We also trim the fat off of the edges to give us some nice even numbers to work with and  assure that each piece can appropriately swap ‘slots’ with others.  &lt;/p&gt;
&lt;p&gt;Next we use our new puzzle piece values to determine the total size of the puzzle and set these values to &lt;code&gt;_puzzleWidth&lt;/code&gt; and &lt;code&gt;_puzzleHeight&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Lastly, we call off a few functions &amp;#8211; &lt;code&gt;setCanvas()&lt;/code&gt; and &lt;code&gt;initPuzzle()&lt;/code&gt;. &lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 5:&lt;/span&gt; The &lt;code&gt;setCanvas()&lt;/code&gt; Function&lt;/h2&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 37; title: ; notranslate"&gt;
function setCanvas(){
    _canvas = document.getElementById('canvas');
    _stage = _canvas.getContext('2d');
    _canvas.width = _puzzleWidth;
    _canvas.height = _puzzleHeight;
    _canvas.style.border = &amp;quot;1px solid black&amp;quot;;
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Now that our puzzle values are complete, we want to set up our &lt;code&gt;canvas&lt;/code&gt; element.  First we set our &lt;code&gt;_canvas&lt;/code&gt; variable to reference our &lt;code&gt;canvas&lt;/code&gt; element, and &lt;code&gt;_stage&lt;/code&gt; to reference its &lt;code&gt;context&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now we set the &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; of our &lt;code&gt;canvas&lt;/code&gt; to match the size of our trimmed image,  followed by applying some simple styles to create a black border around our &lt;code&gt;canvas&lt;/code&gt; to display the bounds of our puzzle.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 6:&lt;/span&gt; The &lt;code&gt;initPuzzle()&lt;/code&gt; Function&lt;/h2&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 44; title: ; notranslate"&gt;
function initPuzzle(){
    _pieces = [];
    _mouse = {x:0,y:0};
    _currentPiece = null;
    _currentDropPiece = null;
    _stage.drawImage(_img, 0, 0, _puzzleWidth, _puzzleHeight, 0, 0, _puzzleWidth, _puzzleHeight);
    createTitle(&amp;quot;Click to Start Puzzle&amp;quot;);
    buildPieces();
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Here we initialize the puzzle.  We set this function up in such a way that we can call it again later when we want to replay the puzzle.  Anything else that needed to be set prior to playing will not need to be set again.&lt;/p&gt;
&lt;p&gt;First we set &lt;code&gt;_pieces&lt;/code&gt; as an empty &lt;code&gt;array&lt;/code&gt; and create the &lt;code&gt;_mouse&lt;/code&gt; object, which will hold our mouse position throughout the application.  Next we set the &lt;code&gt;_currentPiece&lt;/code&gt; and &lt;code&gt;_currentPieceDrop&lt;/code&gt; to &lt;code&gt;null&lt;/code&gt;.  (On the first play these values would already be &lt;code&gt;null&lt;/code&gt;, but we want to make sure they get reset when replaying the puzzle.)   &lt;/p&gt;
&lt;p&gt;Finally, it’s time to draw! First we draw the entire image to display to the player what they will be creating.  After that we create some simple instructions by calling our &lt;code&gt;createTitle()&lt;/code&gt; function.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 7:&lt;/span&gt; The &lt;code&gt;createTitle()&lt;/code&gt; Function&lt;/h2&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 53; title: ; notranslate"&gt;
function createTitle(msg){
    _stage.fillStyle = &amp;quot;#000000&amp;quot;;
    _stage.globalAlpha = .4;
    _stage.fillRect(100,_puzzleHeight - 40,_puzzleWidth - 200,40);
    _stage.fillStyle = &amp;quot;#FFFFFF&amp;quot;;
    _stage.globalAlpha = 1;
    _stage.textAlign = &amp;quot;center&amp;quot;;
    _stage.textBaseline = &amp;quot;middle&amp;quot;;
    _stage.font = &amp;quot;20px Arial&amp;quot;;
    _stage.fillText(msg,_puzzleWidth / 2,_puzzleHeight - 20);
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Here we create a fairly simple message that instructs the user to click the puzzle to begin.&lt;br /&gt;
Our message will be a semi-transparent rectangle that will serve as the background of our text.  This allows the user to see the image behind it and also assures our white text will be legible on any image&lt;/p&gt;
&lt;p&gt;We simply set &lt;code&gt;fillStyle&lt;/code&gt; to black and &lt;code&gt;globalAlpha&lt;/code&gt; to &lt;code&gt;.4&lt;/code&gt;, before filling in a short black rectangle at the bottom of the image.&lt;/p&gt;
&lt;p&gt;Since &lt;code&gt;globalAlpha&lt;/code&gt; affects the entire canvas, we need to set it back to &lt;code&gt;1&lt;/code&gt; (opaque) before drawing the text.  To set up our title, we set the &lt;code&gt;textAlign&lt;/code&gt; to &amp;#8216;center&amp;#8217; and the &lt;code&gt;textBaseline&lt;/code&gt; to &lt;code&gt;'middle'&lt;/code&gt;. We can also apply some &lt;code&gt;font&lt;/code&gt; properties.&lt;/p&gt;
&lt;p&gt;To draw the text, we use the &lt;code&gt;fillText()&lt;/code&gt; method. We pass in the &lt;code&gt;msg&lt;/code&gt; variable and place it at the horizontal center of the &lt;code&gt;canvas&lt;/code&gt;, and the vertical center of the rectangle.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 8:&lt;/span&gt; The &lt;code&gt;buildPieces()&lt;/code&gt; Function&lt;/h2&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 64; title: ; notranslate"&gt;
function buildPieces(){
    var i;
    var piece;
    var xPos = 0;
    var yPos = 0;
    for(i = 0;i &amp;lt; PUZZLE_DIFFICULTY * PUZZLE_DIFFICULTY;i++){
        piece = {};
        piece.sx = xPos;
        piece.sy = yPos;
        _pieces.push(piece);
        xPos += _pieceWidth;
        if(xPos &amp;gt;= _puzzleWidth){
            xPos = 0;
            yPos += _pieceHeight;
        }
    }
    document.onmousedown = shufflePuzzle;
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Finally it&amp;#8217;s time to build the puzzle!&lt;/p&gt;
&lt;p&gt;We do this by building an &lt;code&gt;object&lt;/code&gt; for each piece.  These objects will not be responsible for rendering to the canvas, but rather to merely hold references on what to draw and where. That being said, let’s get to it.&lt;/p&gt;
&lt;p&gt;First off, let’s declare a few variables that we’ll be reusing through the loop.  We want to set up the loop to iterate through the number of puzzle pieces we need.  We get this value by multiplying &lt;code&gt;PUZZLE_DIFFICULTY&lt;/code&gt; by itself &amp;#8211; so in this case we get 16.&lt;/p&gt;
&lt;h3&gt;In the loop:&lt;/h3&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 69; title: ; notranslate"&gt;
    for(i = 0;i &amp;lt; PUZZLE_DIFFICULTY * PUZZLE_DIFFICULTY;i++){
        piece = {};
        piece.sx = xPos;
        piece.sy = yPos;
        _pieces.push(piece);
        xPos += _pieceWidth;
        if(xPos &amp;gt;= _puzzleWidth){
            xPos = 0;
            yPos += _pieceHeight;
        }
    }
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Start by creating an empty &lt;code&gt;piece&lt;/code&gt; object.  Next add the &lt;code&gt;sx&lt;/code&gt; and &lt;code&gt;sy&lt;/code&gt; properties to the object.  In the first iteration, these values are &lt;code&gt;0&lt;/code&gt; and represent the point in our image where we will begin to draw from.  Now push it to the &lt;code&gt;_pieces[]&lt;/code&gt; array.  This object will also contain the properties &lt;code&gt;xPos&lt;/code&gt; and &lt;code&gt;yPos&lt;/code&gt;, which will tell us the current position in the puzzle where the piece should be drawn.  We’ll be shuffling the objects before its playable so these values don’t need to be set quite yet.&lt;/p&gt;
&lt;p&gt;The last thing we do in each loop is increase the local variable &lt;code&gt;xPos&lt;/code&gt; by &lt;code&gt;_pieceWidth&lt;/code&gt;.  Before continuing on with the loop, we determine if we need to step down to the next row of pieces by checking whether &lt;code&gt;xPos&lt;/code&gt; is beyond the width of the puzzle.  If so, we reset &lt;code&gt;xPos&lt;/code&gt; back to 0 and increase &lt;code&gt;yPos&lt;/code&gt; by &lt;code&gt;_pieceHeight&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Now we have our puzzle pieces all stored away nicely in our &lt;code&gt;_pieces&lt;/code&gt; array.  At this point the code finally stops executing and waits for the user to interact.  We set a click listener to the &lt;code&gt;document&lt;/code&gt; to fire the &lt;code&gt;shufflePuzzle()&lt;/code&gt; function when triggered, which will begin the game. &lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 9:&lt;/span&gt; The &lt;code&gt;shufflePuzzle()&lt;/code&gt; Function&lt;/h2&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 82; title: ; notranslate"&gt;
function shufflePuzzle(){
    _pieces = shuffleArray(_pieces);
    _stage.clearRect(0,0,_puzzleWidth,_puzzleHeight);
    var i;
    var piece;
    var xPos = 0;
    var yPos = 0;
    for(i = 0;i &amp;lt; _pieces.length;i++){
        piece = _pieces[i];
        piece.xPos = xPos;
        piece.yPos = yPos;
        _stage.drawImage(_img, piece.sx, piece.sy, _pieceWidth, _pieceHeight, xPos, yPos, _pieceWidth, _pieceHeight);
        _stage.strokeRect(xPos, yPos, _pieceWidth,_pieceHeight);
        xPos += _pieceWidth;
        if(xPos &amp;gt;= _puzzleWidth){
            xPos = 0;
            yPos += _pieceHeight;
        }
    }
    document.onmousedown = onPuzzleClick;
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 212; title: ; notranslate"&gt;
function shuffleArray(o){
    for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
    return o;
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;First things first: shuffle the &lt;code&gt;_pieces[]&lt;/code&gt; array.  I’m using a nice utility function here that will shuffle the indices of the array passed into it.  The explanation of this function is beyond the topic of this tutorial so we’ll move on, knowing that we have successfully shuffled our pieces. (For a basic introduction to shuffling, &lt;a href="http://active.tutsplus.com/tutorials/actionscript/quick-tip-how-to-randomly-shuffle-an-array-in-as3/"&gt;take a look at this tutorial&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;Let’s first clear all graphics drawn to the &lt;code&gt;canvas&lt;/code&gt; to make way for drawing our pieces. Next, set up the array similar to how we did when first creating our piece objects.  &lt;/p&gt;
&lt;h3&gt;In the loop:&lt;/h3&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 89; title: ; notranslate"&gt;
    for(i = 0;i &amp;lt; _pieces.length;i++){
        piece = _pieces[i];
        piece.xPos = xPos;
        piece.yPos = yPos;
        _stage.drawImage(_img, piece.sx, piece.sy, _pieceWidth, _pieceHeight, xPos, yPos, _pieceWidth, _pieceHeight);
        _stage.strokeRect(xPos, yPos, _pieceWidth,_pieceHeight);
        xPos += _pieceWidth;
        if(xPos &amp;gt;= _puzzleWidth){
            xPos = 0;
            yPos += _pieceHeight;
        }
    }
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;First of all, use the &lt;code&gt;i&lt;/code&gt; variable to set up our reference to the current piece object in the loop. Now we populate the &lt;code&gt;xPos&lt;/code&gt; and &lt;code&gt;yPos&lt;/code&gt; properties I mentioned earlier, which will be &lt;code&gt;0&lt;/code&gt; in our first iteration.&lt;/p&gt;
&lt;p&gt;Now, at long last, we draw our pieces. &lt;/p&gt;
&lt;p&gt;The first parameter of &lt;code&gt;drawImage()&lt;/code&gt; assigns the source of the image we want to draw from. Then use the piece objects &lt;code&gt;sx&lt;/code&gt; and &lt;code&gt;sy&lt;/code&gt; properties, along with &lt;code&gt;_pieceWidth&lt;/code&gt; and &lt;code&gt;_pieceHeight&lt;/code&gt;, to populate the parameters that declare the area of the image in which to draw from.  The last four parameters set the area of the &lt;code&gt;canvas&lt;/code&gt; where we want to draw.  We use the &lt;code&gt;xPos&lt;/code&gt; and &lt;code&gt;yPos&lt;/code&gt; values that we are both building in the loop and assigning to the object.&lt;/p&gt;
&lt;p&gt;Immediately after this we draw a quick stroke around the piece to give it a border, which will separate it nicely from the other pieces.&lt;/p&gt;
&lt;p&gt;Now we wait for the user to grab a piece by setting another &lt;code&gt;click&lt;/code&gt; listener.  This time it will fire an &lt;code&gt;onPuzzleClick()&lt;/code&gt; function.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/403_html5TileSwapPuzzle/html5_canvas_puzzle_shuffled.jpg" alt="Final HTML5 Puzzle" /&gt;&lt;/div&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 10:&lt;/span&gt; The &lt;code&gt;onPuzzleClick()&lt;/code&gt; Function&lt;/h2&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 103; title: ; notranslate"&gt;
function onPuzzleClick(e){
    if(e.layerX || e.layerX == 0){
        _mouse.x = e.layerX - _canvas.offsetLeft;
        _mouse.y = e.layerY - _canvas.offsetTop;
    }
    else if(e.offsetX || e.offsetX == 0){
        _mouse.x = e.offsetX - _canvas.offsetLeft;
        _mouse.y = e.offsetY - _canvas.offsetTop;
    }
    _currentPiece = checkPieceClicked();
    if(_currentPiece != null){
        _stage.clearRect(_currentPiece.xPos,_currentPiece.yPos,_pieceWidth,_pieceHeight);
        _stage.save();
        _stage.globalAlpha = .9;
        _stage.drawImage(_img, _currentPiece.sx, _currentPiece.sy, _pieceWidth, _pieceHeight, _mouse.x - (_pieceWidth / 2), _mouse.y - (_pieceHeight / 2), _pieceWidth, _pieceHeight);
        _stage.restore();
        document.onmousemove = updatePuzzle;
        document.onmouseup = pieceDropped;
    }
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;We know that the puzzle was clicked; now we need to determine what piece was clicked on.  This simple conditional will get us our mouse position on all modern desktop browsers that support &lt;code&gt;canvas&lt;/code&gt;, using either &lt;code&gt;e.layerX&lt;/code&gt; and &lt;code&gt;e.layerY&lt;/code&gt; or &lt;code&gt;e.offsetX&lt;/code&gt; and &lt;code&gt;e.offsetY&lt;/code&gt;.  Use these values to update our &lt;code&gt;_mouse&lt;/code&gt; object by assigning it an &lt;code&gt;x&lt;/code&gt; and a &lt;code&gt;y&lt;/code&gt; property to hold the current mouse position &amp;#8211; in this case, the position where it was clicked.&lt;/p&gt;
&lt;p&gt;In line 112 we then immediately set &lt;code&gt;_currentPiece&lt;/code&gt; to the returned value from our &lt;code&gt;checkPieceClicked()&lt;/code&gt; function. We separate this code because we want to use it later when dragging the puzzle piece.  I’ll explain this function in the next step.&lt;/p&gt;
&lt;p&gt;If the value returned was &lt;code&gt;null&lt;/code&gt;, we simply do nothing, as this implies that the user didn’t actually click on a puzzle piece. However, if we do retrieve a puzzle piece, we want to attach it to the mouse and fade it out a bit to reveal the pieces underneath. So how do we do this?&lt;/p&gt;
&lt;p&gt;First we clear the &lt;code&gt;canvas&lt;/code&gt; area where the piece sat before we clicked it. We use &lt;code&gt;clearRect()&lt;/code&gt; once again, but in this case we pass in only the area obtained from the &lt;code&gt;_currentPiece&lt;/code&gt; object.  Before we redraw it, we want to &lt;code&gt;save()&lt;/code&gt; the context of the canvas before proceeding. This will assure that anything we draw after saving will not simply draw over anything in its way.  We do this because we’ll be slightly fading the dragged piece and want to see the pieces under it.  If we didn’t call &lt;code&gt;save()&lt;/code&gt;, we’d just draw over any graphics in the way &amp;#8211; faded or not.&lt;/p&gt;
&lt;p&gt;Now we draw the image so its center is positioned at the mouse pointer.  The first 5 parameters of &lt;code&gt;drawImage&lt;/code&gt; will always be the same throughout the application.  When clicking, the next two parameters will be updated to center itself to the pointer of the mouse.  The last two parameters, the &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; to draw, will also never change.&lt;/p&gt;
&lt;p&gt;Lastly we call the &lt;code&gt;restore()&lt;/code&gt; method.  This essentially means we are done using the new alpha value and want to restore all properties back to where they were. To wrap up this function we add two more listeners.  One for when we move the mouse (dragging the puzzle piece), and one for when we let go (drop the puzzle piece).&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 11:&lt;/span&gt; The &lt;code&gt;checkPieceClicked()&lt;/code&gt; Function&lt;/h2&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 123; title: ; notranslate"&gt;
function checkPieceClicked(){
    var i;
    var piece;
    for(i = 0;i &amp;lt; _pieces.length;i++){
        piece = _pieces[i];
        if(_mouse.x &amp;lt; piece.xPos || _mouse.x &amp;gt; (piece.xPos + _pieceWidth) || _mouse.y &amp;lt; piece.yPos || _mouse.y &amp;gt; (piece.yPos + _pieceHeight)){
            //PIECE NOT HIT
        }
        else{
            return piece;
        }
    }
    return null;
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Now we need to backtrack a bit.  We were able to determine what piece was clicked, but how did we do it?  It’s pretty simple actually.  What we need to do is loop through all of the puzzle pieces and determine if the click was within the bounds of any of our objects.  If we find one, we return the matched object and end the function.  If we find nothing, we return &lt;code&gt;null&lt;/code&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 12:&lt;/span&gt; The &lt;code&gt;updatePuzzle()&lt;/code&gt; Function&lt;/h2&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 137; title: ; notranslate"&gt;
function updatePuzzle(e){
    _currentDropPiece = null;
    if(e.layerX || e.layerX == 0){
        _mouse.x = e.layerX - _canvas.offsetLeft;
        _mouse.y = e.layerY - _canvas.offsetTop;
    }
    else if(e.offsetX || e.offsetX == 0){
        _mouse.x = e.offsetX - _canvas.offsetLeft;
        _mouse.y = e.offsetY - _canvas.offsetTop;
    }
    _stage.clearRect(0,0,_puzzleWidth,_puzzleHeight);
    var i;
    var piece;
    for(i = 0;i &amp;lt; _pieces.length;i++){
        piece = _pieces[i];
        if(piece == _currentPiece){
            continue;
        }
        _stage.drawImage(_img, piece.sx, piece.sy, _pieceWidth, _pieceHeight, piece.xPos, piece.yPos, _pieceWidth, _pieceHeight);
        _stage.strokeRect(piece.xPos, piece.yPos, _pieceWidth,_pieceHeight);
        if(_currentDropPiece == null){
            if(_mouse.x &amp;lt; piece.xPos || _mouse.x &amp;gt; (piece.xPos + _pieceWidth) || _mouse.y &amp;lt; piece.yPos || _mouse.y &amp;gt; (piece.yPos + _pieceHeight)){
                //NOT OVER
            }
            else{
                _currentDropPiece = piece;
                _stage.save();
                _stage.globalAlpha = .4;
                _stage.fillStyle = PUZZLE_HOVER_TINT;
                _stage.fillRect(_currentDropPiece.xPos,_currentDropPiece.yPos,_pieceWidth, _pieceHeight);
                _stage.restore();
            }
        }
    }
    _stage.save();
    _stage.globalAlpha = .6;
    _stage.drawImage(_img, _currentPiece.sx, _currentPiece.sy, _pieceWidth, _pieceHeight, _mouse.x - (_pieceWidth / 2), _mouse.y - (_pieceHeight / 2), _pieceWidth, _pieceHeight);
    _stage.restore();
    _stage.strokeRect( _mouse.x - (_pieceWidth / 2), _mouse.y - (_pieceHeight / 2), _pieceWidth,_pieceHeight);
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Now back to the dragging.  We call this function when the user moves the mouse.  This is the biggest function of the application as it’s doing several things.  Let’s begin. I&amp;#8217;ll break it down as we go.&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 138; title: ; notranslate"&gt;
    _currentDropPiece = null;
    if(e.layerX || e.layerX == 0){
        _mouse.x = e.layerX - _canvas.offsetLeft;
        _mouse.y = e.layerY - _canvas.offsetTop;
    }
    else if(e.offsetX || e.offsetX == 0){
        _mouse.x = e.offsetX - _canvas.offsetLeft;
        _mouse.y = e.offsetY - _canvas.offsetTop;
    }
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Start by setting &lt;code&gt;_currentDropPiece&lt;/code&gt; to &lt;code&gt;null&lt;/code&gt;.  We need to reset this back to &lt;code&gt;null&lt;/code&gt; on update because of the chance that our piece was dragged back to its home.  We don’t want the previous &lt;code&gt;_currentDropPiece&lt;/code&gt; value hanging around. Next we set the &lt;code&gt;_mouse&lt;/code&gt; object the same way we did on click.&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
    _stage.clearRect(0,0,_puzzleWidth,_puzzleHeight);
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Here we need to do clear all graphics on the canvas.  We essentially need to redraw the puzzle pieces because the object being dragged on top will effect their appearance.  If we didn&amp;#8217;t do this, we’d see some very strange results following the path of our dragged puzzle piece.  &lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 148; title: ; notranslate"&gt;
    var i;
    var piece;
    for(i = 0;i &amp;lt; _pieces.length;i++){
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Begin by setting up our usual pieces loop.&lt;/p&gt;
&lt;h3&gt;In the Loop:&lt;/h3&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 151; title: ; notranslate"&gt;
        piece = _pieces[i];
        if(piece == _currentPiece){
            continue;
        }
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Create our &lt;code&gt;piece&lt;/code&gt; reference as usual.  Next check if the piece we are currently referencing is the same as piece we are dragging. If so, continue the loop.  This will keep the dragged piece&amp;#8217;s home slot empty. &lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 155; title: ; notranslate"&gt;
        _stage.drawImage(_img, piece.sx, piece.sy, _pieceWidth, _pieceHeight, piece.xPos, piece.yPos, _pieceWidth, _pieceHeight);
        _stage.strokeRect(piece.xPos, piece.yPos, _pieceWidth,_pieceHeight);
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Moving on, redraw the puzzle piece using its properties exactly the same way we did when first drew them.  You’ll need to draw the border as well.&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 1; title: ; notranslate"&gt;
        if(_currentDropPiece == null){
            if(_mouse.x &amp;lt; piece.xPos || _mouse.x &amp;gt; (piece.xPos + _pieceWidth) || _mouse.y &amp;lt; piece.yPos || _mouse.y &amp;gt; (piece.yPos + _pieceHeight)){
                //NOT OVER
            }
            else{
                _currentDropPiece = piece;
                _stage.save();
                _stage.globalAlpha = .4;
                _stage.fillStyle = PUZZLE_HOVER_TINT;
                _stage.fillRect(_currentDropPiece.xPos,_currentDropPiece.yPos,_pieceWidth, _pieceHeight);
                _stage.restore();
            }
        }
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Since we have a reference to each object in the loop, we can also use this opportunity to check if the dragged piece is on top of it.  We do this because we want to give the user feedback on what piece it can be dropped on.  Let’s dig into that code now.&lt;/p&gt;
&lt;p&gt;First we want to see if this loop has already produced a drop target.  If so, we don’t need to bother since only one drop target can be possible and any given mouse move.  If not, &lt;code&gt;_currentDropPiece&lt;/code&gt; will be &lt;code&gt;null&lt;/code&gt; and we can proceed into the logic. Since our mouse is in the middle of the dragged piece, all we really need to do is determine what other piece our mouse is over.&lt;/p&gt;
&lt;p&gt;Next, use our handy &lt;code&gt;checkPieceClicked()&lt;/code&gt; function to determine whether the mouse is hovering over the current piece object in the loop. If so, we set the &lt;code&gt;_currentDropPiece&lt;/code&gt; variable and draw a tinted box over the puzzle piece, indicating that it is now the drop target.  &lt;/p&gt;
&lt;p&gt;Remember to &lt;code&gt;save()&lt;/code&gt; and &lt;code&gt;restore()&lt;/code&gt;. Otherwise you’d get the tinted box and not the image underneath.&lt;/p&gt;
&lt;h3&gt;Out of the Loop:&lt;/h3&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; collapse: false; first-line: 171; title: ; notranslate"&gt;
    _stage.save();
    _stage.globalAlpha = .6;
    _stage.drawImage(_img, _currentPiece.sx, _currentPiece.sy, _pieceWidth, _pieceHeight, _mouse.x - (_pieceWidth / 2), _mouse.y - (_pieceHeight / 2), _pieceWidth, _pieceHeight);
    _stage.restore();
    _stage.strokeRect( _mouse.x - (_pieceWidth / 2), _mouse.y - (_pieceHeight / 2), _pieceWidth,_pieceHeight);
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Last but not least we need to redraw the dragged piece.  The code is the same as when we first clicked it, but the mouse has moved so its position will be updated.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 13:&lt;/span&gt; The &lt;code&gt;pieceDropped()&lt;/code&gt; Function&lt;/h2&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 177; title: ; notranslate"&gt;
function pieceDropped(e){
    document.onmousemove = null;
    document.onmouseup = null;
    if(_currentDropPiece != null){
        var tmp = {xPos:_currentPiece.xPos,yPos:_currentPiece.yPos};
        _currentPiece.xPos = _currentDropPiece.xPos;
        _currentPiece.yPos = _currentDropPiece.yPos;
        _currentDropPiece.xPos = tmp.xPos;
        _currentDropPiece.yPos = tmp.yPos;
    }
    resetPuzzleAndCheckWin();
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;OK, the worst is behind us.  We are now successfully dragging a puzzle piece and even getting visual feedback on where it will be dropped.  Now all that is left is to drop the piece. Let’s first remove the listeners right away since nothing is being dragged.&lt;/p&gt;
&lt;p&gt;Next, check that &lt;code&gt;_currentDropPiece&lt;/code&gt; is not &lt;code&gt;null&lt;/code&gt;.  If it is, this means that we dragged it back to the piece&amp;#8217;s home area and not over another slot.  If it’s not &lt;code&gt;null&lt;/code&gt;, we continue with the function.&lt;/p&gt;
&lt;p&gt;What we do now is simply swap the &lt;code&gt;xPos&lt;/code&gt; and &lt;code&gt;yPos&lt;/code&gt; of each piece.  We make a quick temp object as a buffer to hold one of the object&amp;#8217;s values in the swapping process.  At this point, the two pieces both have new &lt;code&gt;xPos&lt;/code&gt; and &lt;code&gt;yPos&lt;/code&gt; values, and will snap into their new homes on the next draw.  That’s what we’ll do now, simultaneously checking whether the game has been won.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 14:&lt;/span&gt; The &lt;code&gt;resetPuzzleAndCheckWin()&lt;/code&gt; Function&lt;/h2&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 189; title: ; notranslate"&gt;
function resetPuzzleAndCheckWin(){
    _stage.clearRect(0,0,_puzzleWidth,_puzzleHeight);
    var gameWin = true;
    var i;
    var piece;
    for(i = 0;i &amp;lt; _pieces.length;i++){
        piece = _pieces[i];
        _stage.drawImage(_img, piece.sx, piece.sy, _pieceWidth, _pieceHeight, piece.xPos, piece.yPos, _pieceWidth, _pieceHeight);
        _stage.strokeRect(piece.xPos, piece.yPos, _pieceWidth,_pieceHeight);
        if(piece.xPos != piece.sx || piece.yPos != piece.sy){
            gameWin = false;
        }
    }
    if(gameWin){
        setTimeout(gameOver,500);
    }
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Once again, clear the &lt;code&gt;canvas&lt;/code&gt; and set up a &lt;code&gt;gameWin&lt;/code&gt; variable, setting it to &lt;code&gt;true&lt;/code&gt; by default.  Now proceed with our all-too-familiar pieces loop.  &lt;/p&gt;
&lt;p&gt;The code here should look familiar so we won’t go over it.  It simply draws the pieces back into their original or new slots.  Within this loop, we want to see if each piece is being drawn in its winning position.  This is simple: we check to see if our &lt;code&gt;sx&lt;/code&gt; and &lt;code&gt;sy&lt;/code&gt; properties match up with &lt;code&gt;xPos&lt;/code&gt; and &lt;code&gt;yPos&lt;/code&gt;.  If not, we know we couldn&amp;#8217;t possibly win the puzzle and set &lt;code&gt;gameWin&lt;/code&gt; to &lt;code&gt;false&lt;/code&gt;.  If we made it through the loop with everyone in their winning places, we set up a quick &lt;code&gt;timeout&lt;/code&gt; to call our &lt;code&gt;gameOver()&lt;/code&gt; method.  (We set a timeout so the screen doesn’t change so drastically upon dropping the puzzle piece.)  &lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 15:&lt;/span&gt; The &lt;code&gt;gameOver()&lt;/code&gt; Function&lt;/h2&gt;
&lt;pre&gt;
&lt;pre class="brush: jscript; first-line: 206; title: ; notranslate"&gt;
function gameOver(){
    document.onmousedown = null;
    document.onmousemove = null;
    document.onmouseup = null;
    initPuzzle();
}
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;This is our last function!  Here we just remove all listeners and call &lt;code&gt;initPuzzle()&lt;/code&gt;, which resets all necessary values and waits for the user to play again.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;&lt;a href="http://d2fhka9tf2vaj2.cloudfront.net/tuts/403_html5TileSwapPuzzle/demo/puzzle.html"&gt;Click here to see the final result.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As you can see, you can do a lot of new creative things in HTML5 using selected bitmap areas of loaded images and drawing.  You can easily extend this application by adding scoring and perhaps even a timer to give it more gameplay.  Another idea would be to increase the difficulty and select a different image in the &lt;code&gt;gameOver()&lt;/code&gt; function, giving the game levels. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/d2o8bDFByJql5MUl-3msEjCVeOg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/d2o8bDFByJql5MUl-3msEjCVeOg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/d2o8bDFByJql5MUl-3msEjCVeOg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/d2o8bDFByJql5MUl-3msEjCVeOg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=hgS1BfLd7IM:2UGjcyxxj70:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=hgS1BfLd7IM:2UGjcyxxj70:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=hgS1BfLd7IM:2UGjcyxxj70:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=hgS1BfLd7IM:2UGjcyxxj70:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=hgS1BfLd7IM:2UGjcyxxj70:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=hgS1BfLd7IM:2UGjcyxxj70:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=hgS1BfLd7IM:2UGjcyxxj70:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=hgS1BfLd7IM:2UGjcyxxj70:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=hgS1BfLd7IM:2UGjcyxxj70:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=hgS1BfLd7IM:2UGjcyxxj70:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Flashtuts/~4/hgS1BfLd7IM" height="1" width="1"/&gt;</description>
		<wfw:commentRss>http://active.tutsplus.com/tutorials/games/create-an-html5-canvas-tile-swapping-puzzle/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://active.tutsplus.com/tutorials/games/create-an-html5-canvas-tile-swapping-puzzle/</feedburner:origLink></item>
		<item>
		<title>Vector Regions: Hiding From a Field of View</title>
		<link>http://feedproxy.google.com/~r/Flashtuts/~3/dAaGcZSwG5Q/</link>
		<comments>http://active.tutsplus.com/tutorials/games/vector-regions-hiding-from-a-field-of-view/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 18:00:20 +0000</pubDate>
		<dc:creator>Kah Shiu Chong</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[artificial intelligence]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[Euclidean vectors]]></category>
		<category><![CDATA[field of view]]></category>
		<category><![CDATA[flash]]></category>
		<guid isPermaLink="false">http://active.tutsplus.com/?p=10736</guid>
		<description>&lt;div class="seriesmeta"&gt;This entry is part 2 of 2 in the series &lt;a href="http://active.tutsplus.com/series/vector-regions/" class="series-531" title="Vector Regions"&gt;Vector Regions&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Previously, we explored the approach of using vector regions to implement the field of view of a turret. Troops approached the turret on open field and no hindrances lay between them. Now suppose there is a hinderance, say a wall, that obscures the visibility of troop from turret; how should we implment that? This tutorial suggest an approach to tackle this issue.&lt;/p&gt;
&lt;p&gt;&lt;span id="more-10736"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;Final Result Preview&lt;/h2&gt;
&lt;p&gt;Let&amp;#8217;s take a look at the final result we will be working towards. Click on the turret at the bottom of the stage to start the simulation.&lt;/p&gt;
&lt;div class="tutorial_image"&gt; &lt;object width="500" height="400" data="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/milestones/Scene1_2.swf" type="application/x-shockwave-flash"&gt;&lt;param name="src" value="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/milestones/Scene1_2.swf" /&gt;&lt;/object&gt; &lt;/div&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 1:&lt;/span&gt; The Basic Concept&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/spot1.jpg" alt="Field of view of turret and attempts to obscure its view." /&gt;&lt;/div&gt;
&lt;p&gt;So here&amp;#8217;s what we try to achieve in this tutorial. Observe the image above. The turret can see the trooper unit if it&amp;#8217;s within turret&amp;#8217;s  field of view (top). Once we place a wall in between the turret and the trooper, the trooper&amp;#8217;s visibility is shielded from turret.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 2:&lt;/span&gt; Recap&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/visibility.png" alt="Troops within visible range." /&gt;&lt;/div&gt;
&lt;p&gt;First of all, let&amp;#8217;s  do a little revision. Say the vector of turret&amp;#8217;s line of sight is P and the vector  from turret to trooper is Q. The trooper is visible to the turret if:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Angle between P and Q is less than the angle of view (in this case 30&amp;deg; on both sides)&lt;/li&gt;
&lt;li&gt;Magnitude of P is more than Q&lt;/li&gt;
&lt;/ul&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 3:&lt;/span&gt; Approach Overview&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/pseudocode.png" alt="A brief pseudo-code of the approach." /&gt;&lt;/div&gt;
&lt;p&gt;Above is the pseudo-code for the approach we shall undertake. Determining whether the trooper is within the turret&amp;#8217;s field of view (FOV) is explained in Step 2. Now let&amp;#8217;s get  to determining whether the trooper is behind a wall. &lt;/p&gt;
&lt;p&gt;We shall use vector operations to achieve this. I&amp;#8217;m sure by the mention of  this, the dot product and cross product quickly come to mind. We shall make a  little detour to revise these two vector operations just to make sure everyone&amp;#8217;s  able to follow.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 4:&lt;/span&gt; Dot and Cross Product between Vectors&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/ops.jpg" alt="Dot and cross products of A &amp;#038; B" /&gt;&lt;/div&gt;
&lt;p&gt;Let&amp;#8217;s revisit the vector operations: dot product and cross  product. This is not a Math class, and we have covered these in more detail before, but still, it&amp;#8217;s good to refresh our memory on  the workings so I&amp;#8217;ve included the image above. The diagram shows &amp;#8220;B dot A&amp;#8221; operation (top right corner) and &amp;#8220;B cross A&amp;#8221; operation (bottom right corner). &lt;/p&gt;
&lt;p&gt;More important are the equations of these operations. Take a look at the image below. &lt;code&gt;|A|&lt;/code&gt; and &lt;code&gt;|B|&lt;/code&gt; refer to the &lt;em&gt;scalar magnitude&lt;/em&gt; of each vector &amp;#8211; the length of the arrow. Note that the dot product relates to the cosine of the angle between the vectors, and the cross product  relates to the sine of the angle between the vectors.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/formula.jpg" alt="Formulas of dot and cross products" /&gt;&lt;/div&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 5: &lt;/span&gt;Sine and Cosine&lt;/h2&gt;
&lt;p&gt;Drilling further into the topic, Trigonometry comes to play: the sine and cosine.  Im sure these graphs rekindle fond memories (or agonies). Do click on the  buttons on Flash presentation below to view those graphs with different units  (degrees or radians). &lt;/p&gt;
&lt;div class="tutorial_image"&gt; &lt;object width="450" height="300" data="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/Graphs.swf" type="application/x-shockwave-flash"&gt;&lt;param name="src" value="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/Graphs.swf" /&gt;&lt;/object&gt; &lt;/div&gt;
&lt;p&gt;Note that these wave forms are continuous and repetitive. For example, you can cut  and paste the sine wave into the negative range to get something like below.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/continuous.png" alt="Two portions of sine wave." /&gt;&lt;/div&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 6:&lt;/span&gt; Summary of Values&lt;/h2&gt;
&lt;table style="width: 100%"&gt;
&lt;tr&gt;
&lt;td&gt;Degree&lt;/td&gt;
&lt;td&gt;Sine of degree&lt;/td&gt;
&lt;td&gt;Cosine of degree&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-180&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;-1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-90&lt;/td&gt;
&lt;td&gt;-1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;90&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;180&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;-1&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;The table above shows the cosine and sine values corresponding to specific  degrees. You&amp;#8217;ll notice the positive sine graph covers 0&amp;deg; to 180&amp;deg; range and positive  cosine graph covers -90&amp;deg; to 90&amp;deg;. We shall relate these  values to the dot product and cross product later.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 7:&lt;/span&gt; Geometric Interpretation of Dot Product&lt;/h2&gt;
&lt;p&gt;So how can all these be useful? To cut to the chase, the dot product is a  measure of how &lt;em&gt;parallel&lt;/em&gt; the vectors are whereas cross product is a measure of how &lt;em&gt;orthogonal&lt;/em&gt; the vectors are.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/geometry.jpg" alt="Interpretation on geometry" /&gt;&lt;/div&gt;
&lt;p&gt;Lets deal with the dot product first. Recall the formula for the dot product, as  mentioned in Step 4. We can determine the whether result is positive or  negative just by looking at the cosine of the angle sandwiched between the two vectors.  Why? Because the magnitude of a vector is always positive. The only parameter left  to dictate the sign of the result is the cosine of the angle.&lt;/p&gt;
&lt;p&gt;Again, recall that positive cosine graph covers -90&amp;deg; &amp;#8211; 90&amp;deg;, as in Step 6. Therefore, the dot product of A with any of the vecotrs L, M, N, O above will produce a positive value, because the angle wedged between A and any of those vectors is within -90&amp;deg; and 90&amp;deg;! (To be precise,  the positive range is more like -89&amp;deg; &amp;#8211; 89&amp;deg; because both -90&amp;deg; and 90&amp;deg; produces cosine values of 0, which brings us to the next  point.) The dot product between A and P (given P is perpendicular to A) will produce 0. The rest I think you can already guess: the dot product of A with K, R, or Q will  produce a negative value.&lt;/p&gt;
&lt;p&gt;By using the dot product, we can split the area on our stage into two regions. The dot product of the vector below with any  point that lies inside of the &amp;quot;x&amp;quot;-marked region will produce a positive value, whereas the dot product with those in the &amp;quot;o&amp;quot;-marked region will produce negative values.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/dotRegions.jpg" alt="Dot region divides area into two." /&gt;&lt;/div&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 8:&lt;/span&gt; Geometric Interpretation of Cross Product&lt;/h2&gt;
&lt;p&gt;Let&amp;#8217;s move on to the cross product. Remember that the cross product  relates to the &lt;em&gt;sine&lt;/em&gt; of angle sandwiched between the two vectors. The positive sine graph covers a range of 0&amp;deg; to 180&amp;deg;; the negative range covers 0&amp;deg; to -180&amp;deg;. The image below  summarises these points. &lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/cross.jpg" alt="Positive and negative cross product." /&gt;&lt;/div&gt;
&lt;p&gt;So, looking again at the diagram from Step 7, the cross product  between A and K, L, or M will produce positive values, while the cross product between A and  N, O, P, or Q will produce negative values. The cross product  between A and R will produce 0, as sine of 180&amp;deg; is 0.&lt;/p&gt;
&lt;p&gt;To clarify further, the cross product of vector between any point that lies in the  &amp;quot;o&amp;quot;-marked region below will be positive, whereas those in &amp;quot;x&amp;quot;-marked region will be negative. &lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/vecRegions.jpg" alt="Cross region divides area into 2." /&gt;&lt;/div&gt;
&lt;p&gt;One point to take note of is that,  unlike the dot product, the cross product is sequence sensitive. This means results of &lt;code&gt;AxB&lt;/code&gt; and &lt;code&gt;BxA&lt;/code&gt; will be different in terms of direction. So as we write our program, we  need to be precise when choosing which vector to be compared against.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;(Note: These concepts explained apply to 2D Cartesian space.)&lt;/em&gt;&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 9:&lt;/span&gt; Demo Application&lt;/h2&gt;
&lt;p&gt;To reinforce your understanding, I&amp;#8217;ve placed here a little application to let  you play with. Click on the blue ball at the top of stage and drag it around.  As you move, the text box value will update depending on which operation you  have chosen (dot or cross product between the static arrow with the one you control). &lt;/p&gt;
&lt;div class="tutorial_image"&gt; &lt;object width="400" height="300" data="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/Products.swf" type="application/x-shockwave-flash"&gt;&lt;param name="src" value="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/Products.swf" /&gt;&lt;/object&gt; &lt;/div&gt;
&lt;p&gt;You may observe one oddity with the cross product&amp;#8217;s inverted direction. The  region on top is negative and the bottom is positive, in contrast with our  explanation in previous step. Well, this is due to the y-axis being inverted in  Flash coordinate space compared to Cartesian coordinate space; it points down, whereas traditionally mathematicians take it as pointing upwards.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 10:&lt;/span&gt; Defining Regions&lt;/h2&gt;
&lt;p&gt;Now that you have understood the concept of regions, let&amp;#8217;s do a little  practice. We shall divide our  space into four quadrants: A1, A2, B1, B2.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/regions.jpg" alt="Space divided into 4 regions." /&gt;&lt;/div&gt;
&lt;p&gt;I&amp;#8217;ve tabulated the results to check for below. &amp;#8220;Vector&amp;#8221; here refers to the arrow  in the image above. &amp;#8220;Point&amp;#8221; refers to any coordinate in the specified region. The vector  divides the stage into four main areas, where the dividers (dotted lines) extend to infinity.&lt;/p&gt;
&lt;table style="width: 100%"&gt;
&lt;tr&gt;
&lt;td&gt;Region&lt;/td&gt;
&lt;td&gt;Vector on diagram cross product with point&lt;/td&gt;
&lt;td&gt;Vector on diagram dot product with point&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A1&lt;/td&gt;
&lt;td&gt;(+), because of Flash coordinate space&lt;/td&gt;
&lt;td&gt;(+)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A2&lt;/td&gt;
&lt;td&gt;(+)&lt;/td&gt;
&lt;td&gt;(-)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B1&lt;/td&gt;
&lt;td&gt;(-), because of Flash coordinate space&lt;/td&gt;
&lt;td&gt;(+)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B2&lt;/td&gt;
&lt;td&gt;(-)&lt;/td&gt;
&lt;td&gt;(-)&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 11:&lt;/span&gt; Regions Divided&lt;/h2&gt;
&lt;p&gt;Here&amp;#8217;s the Flash presentation showcasing the ideas as explained in step  10. Right click on  stage to pop the context menu and select the region you would like to  see highlighted.&lt;/p&gt;
&lt;div class="tutorial_image"&gt; &lt;object width="400" height="300" data="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/milestones/Regions.swf" type="application/x-shockwave-flash"&gt;&lt;param name="src" value="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/milestones/Regions.swf" /&gt;&lt;/object&gt; &lt;/div&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 12:&lt;/span&gt; Implementation&lt;/h2&gt;
&lt;p&gt;Here&amp;#8217;s the ActionScript implementation of the concept explained in Step 10.  Feel free to view the whole piece of code in the source download, as &lt;code&gt;AppLine.as&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; first-line: 65; title: ; notranslate"&gt;
//highlighting color according to user selection
private function color():void
{
	//each ball on stage is checked against conditions for selected case
	for each (var item:Ball in sp)
	{
		var vec1:Vector2D = new Vector2D(item.x - stage.stageWidth * 0.5, item.y - stage.stageHeight * 0.5);

		if (select == 0) {
			if (vec.vectorProduct(vec1) &amp;gt; 0) item.col = 0xFF9933;
			else item.col = 0x334455;
		}
		else if (select == 1){
			if (vec.dotProduct(vec1) &amp;gt; 0) item.col = 0xFF9933;
			else item.col = 0x334455;
		}
		else if (select == 2){
			if (vec.vectorProduct(vec1) &amp;gt; 0 &amp;amp;&amp;amp; vec.dotProduct(vec1) &amp;gt; 0) item.col = 0xFF9933;
			else item.col = 0x334455;
		}
		else if (select == 3){
			if (vec.vectorProduct(vec1) &amp;gt; 0 &amp;amp;&amp;amp;vec.dotProduct(vec1) &amp;lt;0) item.col = 0xFF9933;
			else item.col = 0x334455;
		}
		else if (select == 4){
			if (vec.vectorProduct(vec1) &amp;lt; 0 &amp;amp;&amp;amp;vec.dotProduct(vec1) &amp;gt; 0) item.col = 0xFF9933;
			else item.col = 0x334455;
		}
		else if (select == 5){
			if (vec.vectorProduct(vec1) &amp;lt; 0 &amp;amp;&amp;amp;vec.dotProduct(vec1) &amp;lt; 0) item.col = 0xFF9933;
			else item.col = 0x334455;
		}
		item.draw();
	}
}
//swapping case according to user selction
private function swap(e:ContextMenuEvent):void
{
	if (e.target.caption == &amp;quot;VectorProduct&amp;quot;)	select = 0;
	else if (e.target.caption == &amp;quot;DotProduct&amp;quot;)	select = 1;
	else if (e.target.caption == &amp;quot;RegionA1&amp;quot;)	select = 2;
	else if (e.target.caption == &amp;quot;RegionA2&amp;quot;)	select = 3;
	else if (e.target.caption == &amp;quot;RegionB1&amp;quot;)	select = 4;
	else if (e.target.caption == &amp;quot;RegionB2&amp;quot;)	select = 5;
}&lt;/pre&gt;
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 13:&lt;/span&gt; Shielded Visibility&lt;/h2&gt;
&lt;div class="tutorial_image"&gt; &lt;object width="400" height="300" data="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/TutMov2.swf" type="application/x-shockwave-flash"&gt;&lt;param name="src" value="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/TutMov2.swf" /&gt;&lt;/object&gt; &lt;/div&gt;
&lt;p&gt;Having understood the geometrical interpretations of dot product and cross  product, we shall apply it to our scenario. The Flash presentation above shows variations of the same scenario and summarises the conditions applied to a trooper  shielded by a wall yet inside the turret&amp;#8217;s FOV. You can scroll through the frames using  the arrow buttons. &lt;/p&gt;
&lt;p&gt;The following explanations are based upon the 2D Flash coordinate space. In Frame 1, a wall is placed between the  turret and the trooper. Let A and B be the vectors from the turret to the tail and the head of the wall&amp;#8217;s  vector, respectively. Let C be the vector of the wall, and D be the vector from the tail of the wall to the trooper. Finally, let Q be the vector from the turret to the trooper.&lt;/p&gt;
&lt;p&gt;I have tabulated the resulting conditions below.&lt;/p&gt;
&lt;table style="width: 100%"&gt;
&lt;tr&gt;
&lt;td&gt;Location&lt;/td&gt;
&lt;td&gt;Cross Product&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Troop is in front of wall&lt;/td&gt;
&lt;td&gt;C x D &gt; 0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Troop is behind wall&lt;/td&gt;
&lt;td&gt;C x D &lt; 0&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;This is not the only condition applicable, because we also need to restrict the trooper to within the dotted lines on both sides. Check out frames 2-4 to see the next  set of conditions.&lt;/p&gt;
&lt;table style="width: 100%"&gt;
&lt;tr&gt;
&lt;td&gt;Location&lt;/td&gt;
&lt;td&gt;Cross Product&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Troop is within the sides of the wall.&lt;/td&gt;
&lt;td&gt;Q x A &lt; 0, Q x B &gt; 0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Troop is to the left of the wall&lt;/td&gt;
&lt;td&gt;Q x A &gt; 0, Q x B &gt; 0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Troop is to the right of the wall&lt;/td&gt;
&lt;td&gt;Q x A &lt; 0, Q x B &lt; 0&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;I think my fellow readers can now choose the appropriate conditions to  determine whether the trooper is hidden from view or not. Bear in mind that this set  of conditions are evaluated after we found troop to be within turret&amp;#8217;s FOV  (refer to step 3).&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 14:&lt;/span&gt; Actionscript Implementation&lt;/h2&gt;
&lt;div class="tutorial_image"&gt; 	&lt;img src="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/assets/wall.png" alt="The initial state of the application." /&gt;&lt;/div&gt;
&lt;p&gt;Here&amp;#8217;s the ActionScript implementation of the concepts explained in Step 13.  The image above shows the initial vector of the wall, C. Click and drag the red button below and move it around to see the area shielded. You  may view the full source code in &lt;code&gt;HiddenSector.as&lt;/code&gt;.&lt;/p&gt;
&lt;div class="tutorial_image"&gt; &lt;object width="400" height="300" data="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/milestones/HiddenSector.swf" type="application/x-shockwave-flash"&gt;&lt;param name="src" value="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/milestones/HiddenSector.swf" /&gt;&lt;/object&gt; &lt;/div&gt;
&lt;p&gt;Okay, I hope you have experimented with the red ball, and if you are observant  enough you might have noticed an error. Note there is no area shielded as the  red button moves to the left of the other end of the wall, thus inverting the wall vector to  point to left instead of right. The solution is in the next step.&lt;/p&gt;
&lt;p&gt;However, before that let&amp;#8217;s look at an important ActionScript snippet here  in &lt;code&gt;HiddenSector.as&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; first-line: 43; highlight: [48,52,53,54,55,57,58,59]; title: ; notranslate"&gt;
private function highlight():void {
	var lineOfSight:Vector2D = new Vector2D(0, -50)
	var sector:Number = Math2.radianOf(30);

	for each (var item:Ball in sp) {
		var turret_sp:Vector2D = new Vector2D(item.x - turret.x, item.y - turret.y); //Q

		if (Math.abs(lineOfSight.angleBetween(turret_sp)) &amp;lt; sector) {

			var wall:Vector2D = new Vector2D(wall2.x - wall1.x, wall2.y - wall1.y); //C
			var turret_wall1:Vector2D = new Vector2D(wall1.x - turret.x, wall1.y - turret.y); //A
			var turret_wall2:Vector2D = new Vector2D(wall2.x - turret.x, wall2.y - turret.y); //B
			var wall_sp:Vector2D = new Vector2D (item.x - wall1.x, item.y - wall1.y); //D

			if ( wall.vectorProduct (wall_sp) &amp;lt; 0 // C x D
			&amp;amp;&amp;amp; turret_sp.vectorProduct(turret_wall1) &amp;lt; 0 // Q x A
			&amp;amp;&amp;amp; turret_sp.vectorProduct(turret_wall2) &amp;gt; 0 // Q x B
			) { item.col = 0xcccccc }
			else { item.col = 0; }
			item.draw();
		}
	}
}&lt;/pre&gt;
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 15:&lt;/span&gt; Direction of Wall&lt;/h2&gt;
&lt;p&gt;To solve this issue, we need to know whether the wall vector is pointing to the left or the right. Let&amp;#8217;s say we have a reference vector, R, that&amp;#8217;s always  pointing to the right.&lt;/p&gt;
&lt;table style="width: 100%"&gt;
&lt;tr&gt;
&lt;td&gt;Direction of vector&lt;/td&gt;
&lt;td&gt;Dot Product&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wall is pointing to right (same side as R)&lt;/td&gt;
&lt;td&gt;w . R &gt; 0 &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wall is pointing to left (opposite side of R)&lt;/td&gt;
&lt;td&gt;w . R &lt; 0&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;Of course, there are other ways around this problem but I figure it&amp;#8217;s an  opportunity to utilise concepts expressed in this tutorial, so there you go.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 16:&lt;/span&gt; Actionscript Tweaks&lt;/h2&gt;
&lt;p&gt;Below is a Flash presentation which implements the correction explained in  Step 15. After you have played with it, scroll down to check the ActionScript tweaks.&lt;/p&gt;
&lt;div class="tutorial_image"&gt; &lt;object width="400" height="300" data="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/milestones/HiddenSector2.swf" type="application/x-shockwave-flash"&gt;&lt;param name="src" value="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/milestones/HiddenSector2.swf" /&gt;&lt;/object&gt; &lt;/div&gt;
&lt;p&gt;The changes from the previous implementation are highlighted. Also, the sets of  condition are redefined according to the wall direction:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; first-line: 43; highlight: [46,58,59]; title: ; notranslate"&gt;
private function highlight():void {
	var lineOfSight:Vector2D = new Vector2D(0, -50);
	var sector:Number = Math2.radianOf(30);
	var pointToRight:Vector2D = new Vector2D(10, 0); //added in second version

	for each (var item:Ball in sp) {
		var turret_sp:Vector2D = new Vector2D(item.x - turret.x, item.y - turret.y); //Q

		if (Math.abs(lineOfSight.angleBetween(turret_sp)) &amp;lt; sector) {

			var wall:Vector2D = new Vector2D(wall2.x - wall1.x, wall2.y - wall1.y); //C
			var turret_wall1:Vector2D = new Vector2D(wall1.x - turret.x, wall1.y - turret.y); //A
			var turret_wall2:Vector2D = new Vector2D(wall2.x - turret.x, wall2.y - turret.y); //B
			var wall_sp:Vector2D = new Vector2D (item.x - wall1.x, item.y - wall1.y); //D

			var sides: Boolean; //switches according to wall direction
			if (pointToRight.dotProduct(wall) &amp;gt; 0) {
				sides = wall.vectorProduct (wall_sp) &amp;lt; 0 // C x D
				&amp;amp;&amp;amp; turret_sp.vectorProduct(turret_wall1) &amp;lt; 0 // Q x A
				&amp;amp;&amp;amp; turret_sp.vectorProduct(turret_wall2) &amp;gt; 0 // Q x B
			}
			else {
				sides = wall.vectorProduct (wall_sp) &amp;gt; 0 // C x D
				&amp;amp;&amp;amp; turret_sp.vectorProduct(turret_wall1) &amp;gt; 0 // Q x A
				&amp;amp;&amp;amp; turret_sp.vectorProduct(turret_wall2) &amp;lt; 0 // Q x B
			} 

			if (sides) { item.col = 0xcccccc }
			else { item.col = 0; }
			item.draw();
		}
	}
} &lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Check out the full  source in &lt;code&gt;HiddenSector2.as&lt;/code&gt;.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 17:&lt;/span&gt; Set Up the Wall&lt;/h2&gt;
&lt;p&gt;Now we shall patch our work onto &lt;code&gt;Scene1.as&lt;/code&gt; from the previous  tutorial. First, we shall set up our wall.&lt;/p&gt;
&lt;p&gt;We initiate the variables,&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; first-line: 12; highlight: [15]; title: ; notranslate"&gt;
public class Scene1_2 extends Sprite
{
	private var river:Sprite;
	private var wall_origin:Vector2D, wall:Vector2D; //added in second tutorial

	private var troops:Vector.&amp;lt;Ball&amp;gt;;
	private var troopVelo:Vector.&amp;lt;Vector2D&amp;gt;;
&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;&amp;#8230;then draw the wall for the first time,&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; first-line: 27; highlight: [30]; title: ; notranslate"&gt;
public function Scene1_2() {
	makeTroops();
	makeRiver();
	makeWall(); //added in 2nd tutorial
	makeTurret();
	turret.addEventListener(MouseEvent.MOUSE_DOWN, start);
	function start ():void {
		stage.addEventListener(Event.ENTER_FRAME, move);
	}
}&lt;/pre&gt;
&lt;/pre&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; first-line: 75; title: ; notranslate"&gt;
private function makeWall():void {
	wall_origin = new Vector2D(200, 260); wall = new Vector2D(80, -40);
	graphics.lineStyle(2, 0);
	graphics.moveTo(wall_origin.x, wall_origin.y);
	graphics.lineTo(wall_origin.x + wall.x , wall_origin.y+wall.y);
}&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;&amp;#8230;and redraw on each frame, because the &lt;code&gt;graphics.clear()&lt;/code&gt; call is somewhere  in &lt;code&gt;behaviourTurret()&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; first-line: 118; highlight: [120,121]; title: ; notranslate"&gt;
//added in 2nd tutorial
private function move(e:Event):void {
	behaviourTroops();
	behaviourTurret();
	redrawWall();
}&lt;/pre&gt;
&lt;/pre&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; first-line: 241; title: ; notranslate"&gt;
//added in second tutorial
private function redrawWall():void {
	graphics.lineStyle(2, 0);
	graphics.moveTo(wall_origin.x, wall_origin.y);
	graphics.lineTo(wall_origin.x + wall.x , wall_origin.y+wall.y);
}&lt;/pre&gt;
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 18:&lt;/span&gt; Interaction with Wall&lt;/h2&gt;
&lt;p&gt;Troops will interact with the wall as well. As they collide with the wall,  they will slide along the wall. I will not try to go into details of this as it  has been documented extensively in &lt;a href="http://active.tutsplus.com/tutorials/games/quick-tip-collision-reaction-between-a-circle-and-a-line-segment/"&gt;Collision Reaction Between a Circle and a Line Segment&lt;/a&gt;. I  encourage readers to check that out for further explanation.&lt;/p&gt;
&lt;p&gt;The following snippet lives in the function &lt;code&gt;behaviourTroops()&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; first-line: 135; title: ; notranslate"&gt;
//Version 2
//if wading through river, slow down
//if collide with wall, slide through
//else normal speed
var collideWithRiver:Boolean = river.hitTestObject(troops[i])

var wall_norm:Vector2D = wall.rotate(Math2.radianOf( -90));
var wall12Troop:Vector2D = new Vector2D(troops[i].x - wall_origin.x, troops[i].y - wall_origin.y);
var collideWithWall:Boolean = troops[i].rad &amp;gt; Math.abs(wall12Troop.projectionOn(wall_norm))
&amp;amp;&amp;amp; wall12Troop.getMagnitude() &amp;lt; wall.getMagnitude()
&amp;amp;&amp;amp; wall12Troop.dotProduct(wall) &amp;gt; 0;

if (collideWithRiver) troops[i].y += troopVelo[i].y*0.3;
else if (collideWithWall) {
	//reposition troop
	var projOnNorm:Vector2D = wall_norm.normalise(); projOnNorm.scale(troops[i].rad -1);
	var projOnWall:Vector2D = wall.normalise();
	projOnWall.scale(wall12Troop.projectionOn(wall));
	var reposition:Vector2D = projOnNorm.add(projOnWall);
	troops[i].x = wall_origin.x + reposition.x; troops[i].y = wall_origin.y + reposition.y;

	//slide through the wall
	var adjustment:Number = Math.abs(troopVelo[i].projectionOn(wall_norm));
	var slideVelo:Vector2D = wall_norm.normalise(); slideVelo.scale(adjustment);
	slideVelo = slideVelo.add(troopVelo[i])
	troops[i].x += slideVelo.x; troops[i].y += slideVelo.y;
}
else troops[i].y += troopVelo[i].y&lt;/pre&gt;
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 19:&lt;/span&gt; Checking Troopers&amp;#8217; &amp;quot;Hidden-ness&amp;quot;&lt;/h2&gt;
&lt;p&gt;Finally, we come to the meat of this tutorial: setting up the condition and  checking whether troopers are behind the wall and therefore shielded from turret  visibility. I have highlighted the important patch codes:&lt;/p&gt;
&lt;pre&gt;
&lt;pre class="brush: as3; first-line: 218; highlight: [227,228,229,230,233]; title: ; notranslate"&gt;
//check if enemy is within sight
//1. Within sector of view
//2. Within range of view
//3. Closer than current closest enemy
var c1:Boolean = Math.abs(lineOfSight.angleBetween(turret2Item)) &amp;lt; Math2.radianOf(sectorOfSight) ;
var c2:Boolean = turret2Item.getMagnitude() &amp;lt; lineOfSight.getMagnitude();
var c3:Boolean = turret2Item.getMagnitude() &amp;lt; closestDistance;

//Checking whether troop is shielded by wall
var withinLeft:Boolean = turret2Item.vectorProduct(turret2wall1) &amp;lt; 0
var withinRight:Boolean = turret2Item.vectorProduct(turret2wall2) &amp;gt; 0
var behindWall:Boolean = wall.vectorProduct(wall12troop) &amp;lt; 0;
var shielded:Boolean = withinLeft &amp;amp;&amp;amp; withinRight &amp;amp;&amp;amp; behindWall

//if all conditions fulfilled, update closestEnemy
if (c1 &amp;amp;&amp;amp; c2&amp;amp;&amp;amp; c3 &amp;amp;&amp;amp; !shielded){
	closestDistance = turret2Item.getMagnitude();
	closestEnemy = item;
}&lt;/pre&gt;
&lt;/pre&gt;
&lt;p&gt;Check out the full  code in &lt;code&gt;Scene1_2.as&lt;/code&gt;.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 20:&lt;/span&gt; Lauch the Application&lt;/h2&gt;
&lt;p&gt;Finally, we can sit back and check out the patch in action. Hit Ctrl + Enter to see the results of your work. I have included a copy of the working Flash presentation below.  Click on  the turret at the bottom of the stage to start the simulation.&lt;/p&gt;
&lt;div class="tutorial_image"&gt; &lt;object width="500" height="400" data="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/milestones/Scene1_2.swf" type="application/x-shockwave-flash"&gt;&lt;param name="src" value="http://d2fhka9tf2vaj2.cloudfront.net/tuts/402_vectorRegions2/milestones/Scene1_2.swf" /&gt;&lt;/object&gt; &lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/PE95HL8GoMUaOW0c7xMwGfT6G6w/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PE95HL8GoMUaOW0c7xMwGfT6G6w/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/PE95HL8GoMUaOW0c7xMwGfT6G6w/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PE95HL8GoMUaOW0c7xMwGfT6G6w/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=dAaGcZSwG5Q:2NPuRz9J9HM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=dAaGcZSwG5Q:2NPuRz9J9HM:D7DqB2pKExk"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=dAaGcZSwG5Q:2NPuRz9J9HM:D7DqB2pKExk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=dAaGcZSwG5Q:2NPuRz9J9HM:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=dAaGcZSwG5Q:2NPuRz9J9HM:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=dAaGcZSwG5Q:2NPuRz9J9HM:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=dAaGcZSwG5Q:2NPuRz9J9HM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=dAaGcZSwG5Q:2NPuRz9J9HM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/Flashtuts?a=dAaGcZSwG5Q:2NPuRz9J9HM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/Flashtuts?i=dAaGcZSwG5Q:2NPuRz9J9HM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Flashtuts/~4/dAaGcZSwG5Q" height="1" width="1"/&gt;</description>
		<wfw:commentRss>http://active.tutsplus.com/tutorials/games/vector-regions-hiding-from-a-field-of-view/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<series:name><![CDATA[Vector Regions]]></series:name>
	<feedburner:origLink>http://active.tutsplus.com/tutorials/games/vector-regions-hiding-from-a-field-of-view/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 0.748 seconds -->

