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

<channel>
	<title>Cameron McKay &#187; Flash</title>
	<atom:link href="http://cdmckay.org/blog/category/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://cdmckay.org/blog</link>
	<description>Programming and Game Development</description>
	<lastBuildDate>Mon, 14 May 2012 21:11:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Trimming in ActionScript jQuery-style</title>
		<link>http://cdmckay.org/blog/2010/04/07/trimming-in-actionscript-jquery-style/</link>
		<comments>http://cdmckay.org/blog/2010/04/07/trimming-in-actionscript-jquery-style/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 18:26:45 +0000</pubDate>
		<dc:creator>cdmckay</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://cdmckay.org/blog/?p=1344</guid>
		<description><![CDATA[Sometimes we want to remove whitespace from the ends of our strings. In fact, this task is so common on the web that the ubiquitous jQuery library includes a utility method for that purpose. What about in ActionScript 3? Well, not so much. The String class in AS3 is, in my opinion, a bit lacking [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes we want to remove whitespace from the ends of our strings.  In fact, this task is so common on the web that <a href="http://jquery.com">the ubiquitous jQuery library</a> includes <a href="http://api.jquery.com/jQuery.trim/">a utility method</a> for that purpose.</p>
<p>What about in ActionScript 3?  Well, not so much.  The <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/String.htm">String class in AS3 is</a>, in my opinion, a bit lacking compared to languages like <a href="http://msdn.microsoft.com/en-us/library/system.string.aspx">C#</a> and <a href="http://www.scala-lang.org/docu/files/api/scala/runtime/RichString.html">Scala</a>.  What&#8217;s worse, you can&#8217;t augment prototypes easily like you can in JavaScript to add missing methods (see update at the end for more information on this).</p>
<p><span id="more-1344"></span></p>
<p>So I needed to trim a string in AS3. A quick <a href="http://www.google.ca/#hl=en&#038;safe=off&#038;q=as3+trim">Google search</a> showed a couple so-so methods.  Then I got to thinking: Hey, doesn&#8217;t jQuery have a trim method?  Aren&#8217;t they both ECMAScript languages?  Shouldn&#8217;t something as basic as this be pretty similar in both languages?</p>
<p>The answer was yes to all those questions.  So I popped open <a href="http://code.jquery.com/jquery-1.4.2.js">the jQuery source</a> and did a quick search and found this a few lines into it:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Used for trimming whitespace</span>
rtrim <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/^(\s|\u00A0)+|(\s|\u00A0)+$/g</span><span style="color: #339933;">,</span></pre></div></div>

<p>Perfect.  I created a StringHelper AS3 file, plunked it in, and presto, we have an efficient trimmer in AS3:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> final <span style="color: #9900cc; font-weight: bold;">class</span> StringHelper
<span style="color: #000000;">&#123;</span>               
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> StringHelper<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> trim<span style="color: #000000;">&#40;</span>str<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #0033ff; font-weight: bold;">return</span> str<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #009966; font-style: italic;">/^(\s|\u00A0)+|(\s|\u00A0)+$/g</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> trimStart<span style="color: #000000;">&#40;</span>str<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #0033ff; font-weight: bold;">return</span> str<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #009966; font-style: italic;">/^(\s|\u00A0)+/g</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> trimEnd<span style="color: #000000;">&#40;</span>str<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #0033ff; font-weight: bold;">return</span> str<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">replace</span><span style="color: #000000;">&#40;</span><span style="color: #009966; font-style: italic;">/(\s|\u00A0)+$/g</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<h3>Update</h3>
<p>After this was <a href="http://www.reddit.com/r/flash/comments/bnrsm/trimming_in_actionscript_jquerystyle/">posted on Reddit</a>, <strong>theillustratedlife</strong> made the following comment regarding the prototype chain in ActionScript:</p>
<blockquote><p>
You are supposed to be able to enhance the ECMAScript prototypes, but you might have to call a compiler flag when you do it. If you look in the docs, you&#8217;ll notice that there are ECMAScript prototypes and interchangeable native code classes for the primitive types.</p></blockquote>
<p>After doing a bit more experimenting, it looks like you can fairly easily augment the prototype chain in ActionScript as well.  However, there are some caveats when running AS3 in strict mode.  For example, consider having the String class augmented like so:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">prototype</span><span style="color: #000066; font-weight: bold;">.</span>trim = <span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">return</span> StringHelper<span style="color: #000066; font-weight: bold;">.</span>trim<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>If we try to call the <code>trim()</code> method in the usual way</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> str<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;foo&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
str<span style="color: #000066; font-weight: bold;">.</span>trim<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>we&#8217;ll get a compile-time error because the AS3 compiler can&#8217;t find the method in the String class definition.  Fortunately, we can get around this by using a dynamic reference</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> str<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;foo&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
str<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;trim&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p>It&#8217;s a lot uglier, but it works.</p>
]]></content:encoded>
			<wfw:commentRss>http://cdmckay.org/blog/2010/04/07/trimming-in-actionscript-jquery-style/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SpriteFactory &#8212; an AS3 library for creating multiple sprites using the same bitmap</title>
		<link>http://cdmckay.org/blog/2010/04/06/spritefactory-an-as3-library-for-creating-multiple-sprites-using-the-same-bitmap/</link>
		<comments>http://cdmckay.org/blog/2010/04/06/spritefactory-an-as3-library-for-creating-multiple-sprites-using-the-same-bitmap/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 01:18:25 +0000</pubDate>
		<dc:creator>cdmckay</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://cdmckay.org/blog/?p=1336</guid>
		<description><![CDATA[While working on Flash sidescroller stuff I noticed that there was no easy way (that I could find) to create multiple sprites from a single bitmap (something you&#8217;d do when doing a tile-based graphics layout). Sooo&#8230; I made my own simple library called SpriteFactory. Here&#8217;s some example usage: var factory:SpriteFactory = new SpriteFactory&#40;&#34;assets/sprites&#34;&#41;; factory.loadBitmap&#40;&#34;grass&#34;, &#34;block-grass.png&#34;&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>While working on Flash sidescroller stuff I noticed that there was no easy way (that I could find) to create multiple sprites from a single bitmap (something you&#8217;d do when doing a tile-based graphics layout).</p>
<p>Sooo&#8230; <a href="http://cdmckay.org/blog/projects/spritefactory">I made my own simple library called SpriteFactory</a>.</p>
<p>Here&#8217;s some example usage:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> factory<span style="color: #000066; font-weight: bold;">:</span>SpriteFactory = <span style="color: #0033ff; font-weight: bold;">new</span> SpriteFactory<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;assets/sprites&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
factory<span style="color: #000066; font-weight: bold;">.</span>loadBitmap<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;grass&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;block-grass.png&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> grass1<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = factory<span style="color: #000066; font-weight: bold;">.</span>newSprite<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;grass&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> grass2<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span> = factory<span style="color: #000066; font-weight: bold;">.</span>newSprite<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;grass&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></div></div>

<p><a href="http://cdmckay.org/blog/projects/spritefactory">Check out the project page for more information.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cdmckay.org/blog/2010/04/06/spritefactory-an-as3-library-for-creating-multiple-sprites-using-the-same-bitmap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YouTube Basic Sidescroller Tutorial in FlashDevelop</title>
		<link>http://cdmckay.org/blog/2010/04/03/youtube-basic-sidescroller-tutorial-in-flashdevelop/</link>
		<comments>http://cdmckay.org/blog/2010/04/03/youtube-basic-sidescroller-tutorial-in-flashdevelop/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 06:07:36 +0000</pubDate>
		<dc:creator>cdmckay</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[flashdevelop]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[sidescroller]]></category>

		<guid isPermaLink="false">http://cdmckay.org/blog/?p=1284</guid>
		<description><![CDATA[As I&#8217;ve made up my mind to learn Flash, and don&#8217;t want to pay a honkin&#8217; amount of cash, I decided to go with a free Flash IDE called FlashDevelop. Since I&#8217;m toying around with the idea of sidescrollers, I did a search for &#8220;Flash sidescroller tutorial&#8221; and found this excellent 3-parter by devnote.org.  Unfortunately [...]]]></description>
			<content:encoded><![CDATA[<p>As I&#8217;ve made up my mind to learn Flash, and don&#8217;t want to pay a <a href="http://www.adobe.com/products/flash/">honkin&#8217;</a> <a href="http://www.fdt.powerflasher.com/">amount</a> of cash, I decided to go with <a href="http://www.flashdevelop.org/wikidocs/index.php?title=Main_Page">a free Flash IDE called FlashDevelop</a>.</p>
<p>Since I&#8217;m toying around with the idea of sidescrollers, I did a search for &#8220;Flash sidescroller tutorial&#8221; and <a href="http://www.youtube.com/watch?v=xQN4VyUVj3Y&amp;NR=1">found this excellent 3-parter</a> by <a href="http://devnote.org">devnote.org</a>.  Unfortunately (for me), the tutorial expects that you&#8217;re using Adobe&#8217;s Flash IDE.  Thus, as a contribution to the web (and myself&#8230; mostly myself), I translated the tutorial to work with FlashDevelop.  Read on to see how I did it, or <a href="http://cdmckay.org/files/BasicSidescrollerTutorial.zip">just grab the source here</a>.</p>
<p><span id="more-1284"></span>There are basically only 3 elements in the DevNote tutorial that require the Flash IDE.  They are the Boundaries, Player and StartMarker MovieClips.</p>
<p>As the StartMarker was just a point, I used the Point class to represent it (and called it <code>_startPos</code> instead).  Since Boundaries and Player were basically sprites, I represented them using the Sprite class.  Here is the pertinent code:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">MovieClip</span> 
<span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _startPos<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Point</span><span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _player<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _boundaries<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>    
    <span style="color: #000066; font-weight: bold;">...</span>
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
        <span style="color: #009900; font-style: italic;">// Assign defaults.</span>
        _startPos = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Point</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
        _player = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _player<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0xff0000<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _player<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">50</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">50</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _player<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _player<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = _startPos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span><span style="color: #000066; font-weight: bold;">;</span>
        _player<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = _startPos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span><span style="color: #000066; font-weight: bold;">;</span>
        <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>_player<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
        _boundaries = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Sprite</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _boundaries<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0x0000ff<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _boundaries<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">40</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">110</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _boundaries<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">drawRect</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">150</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">110</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _boundaries<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineStyle</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span> 0x0000ff<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _boundaries<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">200</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">300</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _boundaries<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">500</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _boundaries<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">500</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _boundaries<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">600</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">100</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _boundaries<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">moveTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">800</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">200</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _boundaries<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">lineTo</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">500</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">200</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        _boundaries<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        <span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>_boundaries<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
        <span style="color: #000066; font-weight: bold;">...</span>
    <span style="color: #000000;">&#125;</span>    
    <span style="color: #000066; font-weight: bold;">...</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>I also change the code slightly in the case of the key handlers (I used constants for the key codes isntead of magic numbers) and used a <code>do ... while</code> loop for the collision detection.</p>
]]></content:encoded>
			<wfw:commentRss>http://cdmckay.org/blog/2010/04/03/youtube-basic-sidescroller-tutorial-in-flashdevelop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

