<?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>shaun smith &#187; Code</title>
	<atom:link href="http://shaun.boyblack.co.za/blog/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://shaun.boyblack.co.za/blog</link>
	<description>Flash, Flex, Ruby - Cape Town, SA</description>
	<lastBuildDate>Wed, 08 Sep 2010 17:56:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Why Ruby Is Fun</title>
		<link>http://shaun.boyblack.co.za/blog/2010/08/24/why-ruby-is-fun/</link>
		<comments>http://shaun.boyblack.co.za/blog/2010/08/24/why-ruby-is-fun/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 23:14:55 +0000</pubDate>
		<dc:creator>shaun</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://shaun.boyblack.co.za/blog/?p=953</guid>
		<description><![CDATA[Some little things I enjoy about Ruby:]]></description>
			<content:encoded><![CDATA[<p>Some little things I enjoy about <a href="http://www.ruby-lang.org/en/">Ruby</a>:<span id="more-953"></span></p>
<p><script src="http://gist.github.com/546533.js"> </script></p>
]]></content:encoded>
			<wfw:commentRss>http://shaun.boyblack.co.za/blog/2010/08/24/why-ruby-is-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clean Code</title>
		<link>http://shaun.boyblack.co.za/blog/2010/08/02/clean-code/</link>
		<comments>http://shaun.boyblack.co.za/blog/2010/08/02/clean-code/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 16:06:42 +0000</pubDate>
		<dc:creator>shaun</dc:creator>
				<category><![CDATA[Banter]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Inspiration]]></category>

		<guid isPermaLink="false">http://shaun.boyblack.co.za/blog/?p=911</guid>
		<description><![CDATA[I recently purchased @unclebobmartin&#8216;s awesome book: Clean Code. What a book! I&#8217;m going to echo a sentiment that often ripples through the Twittersphere: If you are a programmer and you haven&#8217;t read Clean Code you are doing your fellow programmers (and yourself) a great disservice. Seriously. For fun I decided to dig up the worst [...]]]></description>
			<content:encoded><![CDATA[<p>I recently purchased <a title="Uncle Bob on Twitter" href="http://twitter.com/unclebobmartin">@unclebobmartin</a>&#8216;s awesome book: <a title="Clean Code on Amazon" href="http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882">Clean Code</a>. What a book! I&#8217;m going to echo a sentiment that often ripples through the Twittersphere: If you are a programmer and you haven&#8217;t read Clean Code you are doing your fellow programmers (and yourself) a great disservice. Seriously.<br />
<span id="more-911"></span><br />
For fun I decided to dig up the worst code I have ever written &#8211; quite a challenge considering how much terrible code I have produced in my life! Have a look at this beauty:</p>
<p><script src="http://gist.github.com/504823.js"></script></p>
<p>Stupid names, useless comments, multiple levels of abstraction, poor error handling, super deep nesting, etc etc etc. It pretty much breaks every rule in the book. <strong>But the best bit has to be this</strong>:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$rows_to_populate</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$foreign_table</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$foreign_id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$module_name</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$db_row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$field_name</span><span style="color: #339933;">;</span></div></div>
<p>Yes, that&#8217;s right, <strong>a five dimensional array!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://shaun.boyblack.co.za/blog/2010/08/02/clean-code/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>RobotLegs AS3: A DI Driven MVCS Framework for Flash &amp; Flex &#8211; Inspired by PureMVC</title>
		<link>http://shaun.boyblack.co.za/blog/2009/04/16/robotlegs-an-as3-mvcs-framework-for-flash-and-flex-applications-inspired-by-puremvc/</link>
		<comments>http://shaun.boyblack.co.za/blog/2009/04/16/robotlegs-an-as3-mvcs-framework-for-flash-and-flex-applications-inspired-by-puremvc/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 03:07:53 +0000</pubDate>
		<dc:creator>shaun</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Robotlegs]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[mvcs]]></category>
		<category><![CDATA[puremvc]]></category>
		<category><![CDATA[smartypants-ioc]]></category>

		<guid isPermaLink="false">http://shaun.boyblack.co.za/blog/?p=314</guid>
		<description><![CDATA[Want a framework like PureMVC but without Singletons, Service Locators, or casting? Perhaps one with Dependency Injection and Automatic Mediator Registration? Well, you might enjoy RobotLegs AS3: yet another lightweight micro-architecture for Rich Internet Applications. It&#8217;s got the bits that I like about PureMVC (Mediators, Commands and Proxies) without any of the bits that I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://wiki.github.com/darscan/robotlegs"><img class="alignleft size-full wp-image" style="margin: 0px 10px 0px 0pt;" title="RobotLegs AS3" src="http://shaun.boyblack.co.za/blog/wp-content/uploads/2009/04/robotlegslogotiny.png" alt="RobotLegs AS3" width="50" height="50" /></a>Want a framework like PureMVC but without Singletons, Service Locators, or casting? Perhaps one with Dependency Injection and Automatic Mediator Registration?</p>
<p>Well, you might enjoy RobotLegs AS3: yet another lightweight micro-architecture for Rich Internet Applications.</p>
<p><span id="more-314"></span>It&#8217;s got the bits that I like about PureMVC (Mediators, Commands and Proxies) without any of the bits that I&#8217;m not so fond of (Service Locator, Singletons, casting casting casting!).</p>
<p>I&#8217;ve put the source up on GitHub, so feel free to Fork it and make it better:</p>
<p><a title="Robotlegs on GitHub" href="http://github.com/robotlegs/robotlegs-framework">http://github.com/robotlegs/robotlegs-framework</a></p>
<p>Discussion Group:</p>
<p><a title="RobotLegs AS3 Issues" href="http://github.com/darscan/robotlegs/issues"></a><a title="RobotLegs AS3 Discussion Group" href="http://groups.google.com/group/robotlegs">http://groups.google.com/group/robotlegs</a></p>
<p>Here&#8217;s a little demo:<br />
(<strong>Please note</strong>: the API and usage has cleaned up a lot since this demo was built)</p>
<p><a href="http://examples.robotlegs.org/helloflex/"><img class="alignnone size-full wp-image-327" title="RobotLegs Demo App: HelloFlex" src="http://shaun.boyblack.co.za/blog/wp-content/uploads/2009/04/helloflex460.png" alt="RobotLegs Demo App: HelloFlex" width="460" height="460" /></a></p>
<p>You can also view the demo <a title="RobotLegs Demo - HelloFlex" href="http://examples.robotlegs.org/helloflex/">here</a> (with view source).</p>
<p>The demo app is perhaps not so great, but it demonstrates many of the framework&#8217;s features. AND, there isn&#8217;t a single cast in there! No actor casting, no payload casting, not any casting, not even for fun!</p>
<p>I have much to say about this little framework, but it&#8217;s the wrong side of 5am and I&#8217;ve had a crazy long day. In the meantime, you can find some background info <a title="AS3 Dependency Injection and [Autowire]" href="http://shaun.boyblack.co.za/blog/2009/03/13/as3-dependency-injection-and-autowire/">here</a> and <a title="Flexible RIA Architecture" href="http://shaun.boyblack.co.za/blog/2009/02/08/flexible-ria-architecture-puremvc-and-mate/">here</a> if you&#8217;re interested.</p>
<p><strong>Update: <a title="Robotlegs AS3" href="http://www.robotlegs.org/">RobotLegs Lives!</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://shaun.boyblack.co.za/blog/2009/04/16/robotlegs-an-as3-mvcs-framework-for-flash-and-flex-applications-inspired-by-puremvc/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>Execute An AS3 Function After Exactly One Frame &#8211; DelayedFunctionQueue</title>
		<link>http://shaun.boyblack.co.za/blog/2009/04/06/execute-an-as3-function-after-exactly-one-frame-delayedfunctionqueue/</link>
		<comments>http://shaun.boyblack.co.za/blog/2009/04/06/execute-an-as3-function-after-exactly-one-frame-delayedfunctionqueue/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 13:24:47 +0000</pubDate>
		<dc:creator>shaun</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[frame]]></category>

		<guid isPermaLink="false">http://shaun.boyblack.co.za/blog/?p=301</guid>
		<description><![CDATA[I asked this question on Stack Overflow: What&#8217;s the best way to execute a function after exactly one frame? Based on the feedback I wrote a little class to make it super easy to do. You add function references to a queue, and those functions get called (in the order they were added) on the [...]]]></description>
			<content:encoded><![CDATA[<p>I asked this question on Stack Overflow:</p>
<p><a title="Best way to execute a function after exactly one frame?" href="http://stackoverflow.com/questions/671857/best-way-to-execute-a-function-after-exactly-one-frame">What&#8217;s the best way to execute a function after exactly one frame?</a></p>
<p>Based on the feedback I wrote a little class to make it super easy to do. You add function references to a queue, and those functions get called (in the order they were added) on the next Flash Player Frame.</p>
<p>Herewith, the <a title="DelayedFunctionQueue.as" href="http://shaun.boyblack.co.za/blog/wp-content/uploads/2009/04/delayedfunctionqueueas.zip">DelayedFunctionQueue.as</a></p>
<p><span id="more-301"></span></p>
<p>Unpack, and put it in the following folder in your source path: net/boyblack/robotlegs/utils (or edit the package declaration if you want to put it elsewhere).</p>
<p>Usage1: DelayedFunctionQueue.add( func );<br />
Usage2: DelayedFunctionQueue.add( func, arg1, arg2, argn );</p>
]]></content:encoded>
			<wfw:commentRss>http://shaun.boyblack.co.za/blog/2009/04/06/execute-an-as3-function-after-exactly-one-frame-delayedfunctionqueue/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting a Flex ItemRenderer with AS3 Code</title>
		<link>http://shaun.boyblack.co.za/blog/2009/03/19/setting-a-flex-itemrenderer-with-as3-code/</link>
		<comments>http://shaun.boyblack.co.za/blog/2009/03/19/setting-a-flex-itemrenderer-with-as3-code/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 12:48:47 +0000</pubDate>
		<dc:creator>shaun</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://shaun.boyblack.co.za/blog/?p=236</guid>
		<description><![CDATA[itemRenderer = new ClassFactory( ItemRendererClass );]]></description>
			<content:encoded><![CDATA[<p>itemRenderer = new ClassFactory( ItemRendererClass );</p>
]]></content:encoded>
			<wfw:commentRss>http://shaun.boyblack.co.za/blog/2009/03/19/setting-a-flex-itemrenderer-with-as3-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Resizing and Cropping Utility &#8211; AS3 Demo</title>
		<link>http://shaun.boyblack.co.za/blog/2008/08/29/image-resizing-and-cropping-utility-as3-demo/</link>
		<comments>http://shaun.boyblack.co.za/blog/2008/08/29/image-resizing-and-cropping-utility-as3-demo/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 12:56:28 +0000</pubDate>
		<dc:creator>shaun</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://shaun.boyblack.co.za/blog/?p=109</guid>
		<description><![CDATA[Just a little follow up to yesterday&#8217;s post. Kyle was kind enough to put together a little demo for the Display Utility and send it my way. I tweeked it to reduce the filesize a bit. Herewith, the demo, source and all: displayutildemo.zip Disclaimer: My Mac has probably thrown some .DS_Store files into the zip [...]]]></description>
			<content:encoded><![CDATA[<p>Just a little follow up to <a title="Image Resizing and Cropping Utility - AS3" href="http://shaun.boyblack.co.za/blog/2008/08/29/image-resizing-and-cropping-utility/" target="_self">yesterday&#8217;s post</a>.</p>
<p><a title="Kyle Ward" href="http://www.kyleward.co.za/" target="_blank">Kyle</a> was kind enough to put together a little demo for the Display Utility and send it my way. I tweeked it to reduce the filesize a bit. Herewith, the demo, source and all:</p>
<p><a href="http://shaun.boyblack.co.za/blog/wp-content/uploads/2008/08/displayutildemo.zip">displayutildemo.zip</a></p>
<p>Disclaimer: My Mac has probably thrown some .DS_Store files into the zip file. If you are a Windows user.. &#8220;suck it!&#8221; No, I&#8217;m just kidding. The best solution is to switch to OS X as soon as you can: I promise you won&#8217;t regret it. Until you try to copy and merge two folders &#8211; at which point you will be amazed when your original folder gets wiped. Awesome! Apple, why oh why oh why? The best OS on the planet, with one of the biggest flaws imaginable!</p>
]]></content:encoded>
			<wfw:commentRss>http://shaun.boyblack.co.za/blog/2008/08/29/image-resizing-and-cropping-utility-as3-demo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Resizing and Cropping Utility &#8211; AS3</title>
		<link>http://shaun.boyblack.co.za/blog/2008/08/29/image-resizing-and-cropping-utility/</link>
		<comments>http://shaun.boyblack.co.za/blog/2008/08/29/image-resizing-and-cropping-utility/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 23:53:38 +0000</pubDate>
		<dc:creator>shaun</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://shaun.boyblack.co.za/blog/?p=96</guid>
		<description><![CDATA[UPDATE: Aha, here we go, this looks much better: Fit Display Object Into Rectange UPDATE: Or check out CASA lib: http://casalib.org/ A day or two ago my man Kyle asked me if I knew of any good ActionScript image resizing utilities. I said &#8220;nay&#8221;, did a quick (and unsuccessful) search, and promptly forgot about it. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE</strong>: Aha, here we go, this looks much better: <a title="Fit Display Object Into Rectangle" href="http://blog.soulwire.co.uk/flash/actionscript-3/fit-a-displayobject-into-a-rectangle/">Fit Display Object Into Rectange</a><br />
<strong>UPDATE</strong>: Or check out CASA lib: <a title="CASAlib" href="http://casalib.org/">http://casalib.org/</a></p>
<p>A day or two ago my man <a title="Kyle Ward" href="http://www.kyleward.co.za/" target="_blank">Kyle</a> asked me if I knew of any good ActionScript image resizing utilities. I said &#8220;nay&#8221;, did a quick (and unsuccessful) search, and promptly forgot about it. This morning, however, I had to write some PHP to scale and crop images to fit inside fixed rectangles (for desktop downloads) and I remembered that I&#8217;d written something to do that very thing many years ago. I found my old code, tweaked it, and rolled it out.</p>
<p>This evening I decided to write an AS3 version &#8211; I&#8217;ll need it soon enough anyhow. Herewith, my Display Utility containing two static methods: resize(), and resizeAndCrop().</p>
<p>DisplayUtil.resize() will scale a DisplayObject to a target size, with an optional fourth parameter to determine whether the image should fit &#8220;inside&#8221; (default) or &#8220;outside&#8221; the target size. For example:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">var fitInside:Boolean = false;<br />
DisplayUtil.resize( pic, 400, 300, fitInside );</div></div>
<p>DisplayUtil.resizeAndCrop() will scale a DisplayObject to fit &#8220;outside&#8221; a target size and then crop off the excess (by setting a scrollRect on the DisplayObject). The optional fourth and fifth parameters determine how to align the crop (the area to keep &#8211; defaults to center, middle). For example:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">var ha:String = DisplayUtil.ALIGN_RIGHT;<br />
var va:String = DisplayUtil.ALIGN_BOTTOM;<br />
DisplayUtil.resizeAndCrop( pic, 400, 300, ha, va );</div></div>
<p>Download:</p>
<p><a href="http://shaun.boyblack.co.za/blog/wp-content/uploads/2008/08/displayutil1.zip">displayutil.zip</a></p>
<p>Disclaimer: I&#8217;m absolutely sure that someone has already written something to do this, but I couldn&#8217;t find anything easily (quickly) enough, and it was fun to write.</p>
<p><strong>UPDATE</strong>: Aha, here we go, this looks much better: <a title="Fit Display Object Into Rectangle" href="http://blog.soulwire.co.uk/flash/actionscript-3/fit-a-displayobject-into-a-rectangle/">http://blog.soulwire.co.uk/flash/actionscript-3/fit-a-displayobject-into-a-rectangle/</a><br />
<strong>UPDATE</strong>: Or check out CASA lib: <a title="CASAlib" href="http://casalib.org/">http://casalib.org/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://shaun.boyblack.co.za/blog/2008/08/29/image-resizing-and-cropping-utility/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>
