<?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>DogCatFishDish</title>
	<atom:link href="http://www.dogcatfishdish.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.dogcatfishdish.com/blog</link>
	<description>[ insert clever tagline ]</description>
	<lastBuildDate>Sun, 20 May 2012 13:31:04 +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>Cubic bézier curves in Away3D</title>
		<link>http://www.dogcatfishdish.com/blog/?p=176</link>
		<comments>http://www.dogcatfishdish.com/blog/?p=176#comments</comments>
		<pubDate>Sun, 20 May 2012 10:05:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.dogcatfishdish.com/blog/?p=176</guid>
		<description><![CDATA[Recently I was asked to investigate the potential for creating cinematic scenes in-game. These are different from pre rendered scenes as they utilise realtime 3D graphics, which has the advantage of being flexible and easily edited at the cost of visual quality. Creating these cinematic requires precise control over the animation and positioning of the various actors in the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D176"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D176&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Recently I was asked to investigate the potential for creating cinematic scenes in-game. These are different from pre rendered scenes as they utilise realtime 3D graphics, which has the advantage of being flexible and easily edited at the cost of visual quality. Creating these cinematic requires precise control over the animation and positioning of the various actors in the scene, commonly using curved paths to describe the motion of  these actors.</p>
<p>The solution I was investigating required these cinematics to be created in a 3D editor like Maya or Blender, both of which use cubic Bézier curves to create paths. Unfortunatly, Away3D, the 3D engine of choice for the game did not support cubic Bézier curves, only quadratic curves. If you are wondering what the difference is between cubic and quadratic Bézier curves, it is simple the number of control points the curve uses. Quadratic curves have three points &#8211; start, control and end &#8211; whereas cubic curves have four &#8211; start, control, control, end. The <a title="Wikipedia - Bézier curves" href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Constructing_B.C3.A9zier_curves" target="_blank">wikipedia entry for Bézier curves</a> has some simple animations demonstrating the differences.</p>
<p>As you may have guessed the solution to this was to add support for cubic curves into Away3D. I simply duplicated the Path classes to CubicPath classes &#8211; adding the extra control point and changing the path functions to cubic. This worked well, but it resulted in the classes related to path operations being rather disjointed and inflexible &#8211; two animator classes for example. I therefore decided to <a href="https://github.com/bbeaumont/away3d-core-fp11/tree/dev/src/away3d/extrusions/utils" target="_blank">refactor the path classes</a> and abstract them using intefaces, which means there is now a single animator class, to which you pass an IPath interface or either a CubicPath or QuadraticPath.</p>
<p>Here is a <a title="Bézier curve demo" href="http://dogcatfishdish.com/demos/path-animator/" target="_blank">simple demonstration</a> of the new cubic and quadratic curve animations.</p>
<p>Currently, this work is residing in the &#8216;dev&#8217; branch of <a href="https://github.com/bbeaumont/away3d-core-fp11/tree/dev" target="_blank">my own fork of Away3D</a> pending a pull request.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D176&amp;title=Cubic%20b%C3%A9zier%20curves%20in%20Away3D" id="wpa2a_2"><img src="http://www.dogcatfishdish.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.dogcatfishdish.com/blog/?feed=rss2&#038;p=176</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColorMatrixMethod for Away3D</title>
		<link>http://www.dogcatfishdish.com/blog/?p=165</link>
		<comments>http://www.dogcatfishdish.com/blog/?p=165#comments</comments>
		<pubDate>Sat, 19 May 2012 22:44:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[Away3D]]></category>

		<guid isPermaLink="false">http://www.dogcatfishdish.com/blog/?p=165</guid>
		<description><![CDATA[Been a long time since I&#8217;ve written anything. But that&#8217;s all set to change you&#8217;ll be glad to hear. For the past year or so I&#8217;ve been working at Mindshapes, developing a forthcoming game. It&#8217;s been and interesting time, and I&#8217;ve learnt so many new things and used lots of new and exciting technologies. Away3D, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D165"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D165&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Been a long time since I&#8217;ve written anything. But that&#8217;s all set to change you&#8217;ll be glad to hear. For the past year or so I&#8217;ve been working at Mindshapes, developing a forthcoming game.<br />
It&#8217;s been and interesting time, and I&#8217;ve learnt so many new things and used lots of new and exciting technologies. Away3D, AwayPhysics, Maven to name a few. In addition I&#8217;ve also developed a number of useful libraries and tools, some of which I thought I would start documenting here.</p>
<p>First up is the <a title="ColorMatrixMethod" href="https://github.com/away3d/away3d-core-fp11/blob/master/src/away3d/materials/methods/ColorMatrixMethod.as">ColorMatrixMethod</a> for Away3D 4.0. I developed this to answer a need to desaturated meterials on the fly. One approach could have been to create a desaturated bitmap texture for each coloured texture. However, this results in extra bitmaps to be loaded, and makes updating textures that much more of a pain.<br />
Away3D already had a <a title="ColorTransformMethod" href="https://github.com/away3d/away3d-core-fp11/blob/master/src/away3d/materials/methods/ColorTransformMethod.as">ColorTransformMethod</a>, which uses the ColorTransform class as its input, but that doesnt facilitate desaturation, and doesn&#8217;t give the fine control that a color matrix allows.<br />
The ColorMatrixMethod itself is pretty simple, it uses a ColorMatrixFilter as its input and only requires a couple of AGAL instructions to implement. However, using a color matrix is a bit recondite, so it really needs a wrapper for the ColorMatrixFilter which provides more tangible methods for manipulating the matrix &#8211; adjusting saturation, hue, contrast etc. A quick scan of the Internet threw up a fantastically useful <a title="ColorMatrix class" href="http://www.quasimondo.com/colormatrix/ColorMatrix.as">ColorMatrix</a> class, which is used to adjust the raw matrix data in a ColorMatrixFilter.<br />
I&#8217;ve created a <a title="Color matrix method demonstration" href="http://dogcatfishdish.com/demos/color-matrix-method/">simple demonstration</a> to show some of the methods capabilities.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D165&amp;title=ColorMatrixMethod%20for%20Away3D" id="wpa2a_4"><img src="http://www.dogcatfishdish.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.dogcatfishdish.com/blog/?feed=rss2&#038;p=165</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting compiler arguments at runtime</title>
		<link>http://www.dogcatfishdish.com/blog/?p=145</link>
		<comments>http://www.dogcatfishdish.com/blog/?p=145#comments</comments>
		<pubDate>Tue, 29 Mar 2011 20:57:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.dogcatfishdish.com/blog/?p=145</guid>
		<description><![CDATA[Have you ever wondered how runtime shared libraries get into Flex? No? Well, neither did I. Lets face it, it&#8217;s not the hottest or most common thing to arise in the world of Actionscript development. Today, however, I did have a need to understand the process. I&#8217;ve been tasked with building a system for a [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D145"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D145&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Have you ever wondered how runtime shared libraries get into Flex? No? Well, neither did I. Lets face it, it&#8217;s not the hottest or most common thing to arise in the world of Actionscript development.</p>
<p>Today, however, I did have a need to understand the process. I&#8217;ve been tasked with building a system for a large game we are developing, which needs to load modules and RSLs. In a Flex application, this process is hidden as part of it&#8217;s initialisation &#8211; the SystemManager class handles this magic. Pass in the RSL URLs (try saying that quickly ten times) to the compiler, and it&#8217;s loads &#8216;em. Great for Flex, but not so great for us building Actionscript only projects.</p>
<p>My initial research focussed on the mx.managers.SystemManager which is &#8216;possibly the most important class in Flex&#8217;. This has the responsibility of booting up any Flex application. It is the factory class called from any Application subclass (subclass being very important, but more later).</p>
<p>If you look at the SystemManager class, you&#8217;ll notice that it has an info() method that returns an empty Object. If you look at other parts of the class, you&#8217;ll see it referring to data in the info Object (e.g. info()['rsls']). The odd thing is, is that the object info returns is always empty &#8211; return {}; &#8211; so whats going on?</p>
<p>It turns out that SystemManager is actually a base class that has subclasses automagically generated by the compiler. If you use the -keep compiler argument in a Flex project, you&#8217;ll see these generated classes. SystemManager implements IFlexModuleFactory, whose methods (including info()) are actually the ones generated. In the generated class you&#8217;ll see that the info() object now has references to some of the compiler arguments.</p>
<p>So, how do we retrieve this info() info in a non-Flex project?</p>
<p>After a little more research and experimentation I discovered it&#8217;s fairly simple. Firstly we need to create a factory which implements IFlexModuleFactory. In it&#8217;s most basic form, we only need to add a listen to an Event.COMPLETE from the loaderInfo, which then creates and adds the main application class. Also, this factory must extend Movieclip.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Factory<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		loaderInfo.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, onComplete<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onComplete<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">nextFrame</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		addChild<span style="color: #66cc66;">&#40;</span>create<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> as DisplayObject<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Simple enough. Since a subclass of this will  be generated, we need do nothing with any of the other methods.</p>
<p>Now we need to use this factory. Following a similar method to <a href="http://www.bit-101.com/blog/?p=946">creating a preloader</a> we will use the Frame metadata. However, we can&#8217;t exactly follow this. In a seemingly odd move, we have to add the metadata to a superclass of the main application class, not the application class itself. I guess this is because in the flex world, a main application class extends mx.core.Application which has the metadata in it.<br />
Therefore, we create a class that extends Sprite which acts as the application superclass, then extend this to create the actual application class</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
&nbsp;
	<span style="color: #66cc66;">&#91;</span>Frame<span style="color: #66cc66;">&#40;</span>factoryClass=<span style="color: #ff0000;">&quot;factory.Factory&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ApplicationBase <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ApplicationBase<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>I&#8221;ve created a <a href="http://www.dogcatfishdish.com/blog/wp-content/uploads/2011/03/ExtractCompilerArguments.zip">simple project</a> which demonstrates this. I&#8217;ve added a -runtime-shared-libraries compilier argument which you can see in the factory as info()['rsls'].  </p>
<p>Of course, it isn&#8217;t just RSLs you can access, a quick look through the source of SystemManager will reveal others. I&#8217;m sure there are many other uses, and at the very least it gives an interesting insight into what the mxmlc compiler does.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D145&amp;title=Getting%20compiler%20arguments%20at%20runtime" id="wpa2a_6"><img src="http://www.dogcatfishdish.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.dogcatfishdish.com/blog/?feed=rss2&#038;p=145</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Moroccan sausage and mash mash-up</title>
		<link>http://www.dogcatfishdish.com/blog/?p=131</link>
		<comments>http://www.dogcatfishdish.com/blog/?p=131#comments</comments>
		<pubDate>Wed, 17 Nov 2010 14:31:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[food]]></category>

		<guid isPermaLink="false">http://www.dogcatfishdish.com/blog/?p=131</guid>
		<description><![CDATA[Ok, in a decidedly odd tangent I&#8217;m going to post up recipes as well as any computery based posts. I love cooking, as much as I enjoy making things using computers, so why not feature both? Also, my memory for my own recipes is rubbish, so it serves a memory bank. First up is something [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D131"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D131&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Ok, in a decidedly odd tangent I&#8217;m going to post up recipes as well as any computery based posts. I love cooking, as much as I enjoy making things using computers, so why not feature both? Also, my memory for my own recipes is rubbish, so it serves a memory bank.</p>
<p>First up is something I thought up on the way home the other day. I was pondering classic, prosaic food done in an unexpected fashion. Lofty thoughts, but really I was in a Homer Simpson-esque food day dream. Mmm&#8230;sausages. Ok, enough of the dreaming, onto the real food.</p>
<p>Here&#8217;s a Moroccan-ish version of sausage and mash. It combines spicy kofte with a sweet spice-infused butternut squash mash. To got with it is a fresh mint and parsley pesto. It&#8217;s good with a simple chopped salad and a bit of yoghurt.</p>
<h3>Sausages (well, kofte)</h3>
<ul>
<li>500g lamb mince</li>
<li>100g breadcrumbs</li>
<li>1 egg</li>
<li>1 tbsp Ras-al-hanout</li>
<li>1 tsp hot paprika</li>
<li>1 tsp sweet paprika</li>
<li>1/2 onion</li>
<li>1 clove garlic</li>
<li>Parsley</li>
<li>Kebab sticks &#8211; I use bamboo ones</li>
</ul>
<p>Put the onion, garlic, parsley, spices in a food processor and run it for a little bit. Put this in a mixing bowl and add the meat, egg and seasoning. Mix it together for a bit, then add some of  the breadcrumbs. Mix it and add breadcrumbs until it starts to come together and feel doughy.</p>
<p>Once done, break it up into fist sized pieces. Roll each of these out into a rough sausage shape, and poke a stick through the middle of it (lengthways! it&#8217;s not a cocktail sausage). Carefully continue to roll it out until the whole thing resembles a shish kebab.</p>
<p>When they are all done, put them on a plate and into the fridge to harden up for  at least 20 minutes &#8211; this helps to stop them falling apart when cooking. If you can, prepare them a few hours in advance so they marinade and get even better. You can also freeze them.</p>
<p>To cook them, put them under a medium grill until they brown, roughly 15 minutes.</p>
<h3>Squash mash!</h3>
<ul>
<li>1 butternut squash (or any squash really)</li>
<li>Aromatic whole spices such as cloves, cinnamon, aniseed, cardamom, etc.</li>
<li>Cumin seeds for garnish (optional)</li>
<li>Lemon or orange zest</li>
<li>Butter</li>
</ul>
<p>You&#8217;ll need a saucepan with a steamer attachment. If you don&#8217;t have that, get McGyver-like and make up something using a colander. I&#8217;m unsure if you could use a bespoke steamer, the spices get added to the water so might interfere with it. It might be possible to boil it, but I&#8217;ve never done that &#8211; the spices will get mixed up with it unless you put them in a little muslin bag.</p>
<p>In the pan, add an inch of boiling water and put the whole spices in. Peel the squash and slice it into big chunks and put the chunks into the steamer basket. Let the squash steam for about 40 minutes, until it&#8217;s soft and squidgy. As it softens it absorbs the aromas of the spices. While it&#8217;s steaming, make the pesto and anything else you fancy.</p>
<p>When it&#8217;s cooked, put the squash in a colander and drain the water out of the pan and throw away the spices. Add the squash back into the pan, add a knob of butter, and zest. Mash it up, sprinkle over the cumin seeds. Done.</p>
<h3>Mint and parsley pesto</h3>
<ul>
<li>Bunch of fresh mint</li>
<li>Bunch of parsley</li>
<li>Whole almonds</li>
<li>2 clove garlic</li>
<li>Good extra virgin olive oil</li>
</ul>
<p>Toast the almonds in a dry pan until they get a bit of colour on them. Make sure they don&#8217;t get burnt, that tastes awful. When toasted use a big mortar and pestle to break them up into small chunks.</p>
<p>Chop up the herbs and put into the mortar and pestle. Finely chop the garlic and add it. Bash the ingredients together and add the oil a bit at a time until it&#8217;s texture is somewhere between a sauce and a paste, and hey presto! you&#8217;ve got pesto (groan).</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D131&amp;title=Moroccan%20sausage%20and%20mash%20mash-up" id="wpa2a_8"><img src="http://www.dogcatfishdish.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.dogcatfishdish.com/blog/?feed=rss2&#038;p=131</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Anaglyph</title>
		<link>http://www.dogcatfishdish.com/blog/?p=113</link>
		<comments>http://www.dogcatfishdish.com/blog/?p=113#comments</comments>
		<pubDate>Wed, 10 Nov 2010 14:01:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[experiments]]></category>

		<guid isPermaLink="false">http://www.dogcatfishdish.com/blog/?p=113</guid>
		<description><![CDATA[The other day I found a pair of 3d glasses on my desk. You know, the red and green/blue ones which make you look like Dr Jacoby from Twin peaks&#8230; &#8230;or not. I certainly don&#8217;t have such a splendid beard, or (seemingly) a fondness for listening to the cries of unborn chicks. The glasses split [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D113"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D113&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The other day I found a pair of 3d glasses on my desk. You know, the red and green/blue ones which make you look like Dr Jacoby from Twin peaks&#8230;</p>
<p><a href="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/11/tp-jacoby2jpg.jpeg" rel="lightbox[113]"><img class="aligncenter size-full wp-image-118" title="dr-jacoby" src="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/11/tp-jacoby2jpg.jpeg" alt="Dr Jacoby" width="216" height="216" /></a>&#8230;or not. I certainly don&#8217;t have such a splendid beard, or (seemingly) a fondness for listening to the cries of unborn chicks.</p>
<p>The glasses split from a copy of .NET magazine, advertising <a href="http://abductionlamp.com/" target="_blank">The Alien Abduction Lamp</a>, whatever that is. They also seem to have been designed for someone with an alien head shape.</p>
<p>Being at a lose end, I pondered that philosophical question &#8220;Can I make an anaglyph animation in Flash in half an hour?&#8221;. 29 minutes later I had my answer &#8211; a resounding &#8216;Yes&#8217;. Heres the result.</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="450" height="338" align="center">
      <param name="movie" value="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/11/Main2.swf" />
      <param name="align" value="center" />
      <param name="allowfullscreen" value="true" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/11/Main2.swf" width="450" height="338" align="center" allowfullscreen="true">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p>It&#8217;s not perfect by any means, especially the code which is as bizarre and messy as the plot in season two of Twin Peaks.</p>
<p>Achieving the effect is pretty simple in principal. Each textfield (lets call it a virtual textfield) actually consists two textfields &#8211; red and cyan. These two textfields are moved together or pushed apart as the virtual textfield moves back and forth. The distance between the textfields is proportional to the z value of the virtual textfield.</p>
<p>One day I&#8217;d like to find a practical use for this and take it a bit further, but for no it can take it&#8217;s place in the archive next to the &#8216;Early 90&#8242;s TV series&#8217; section.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D113&amp;title=Anaglyph" id="wpa2a_10"><img src="http://www.dogcatfishdish.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.dogcatfishdish.com/blog/?feed=rss2&#038;p=113</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actiondown!</title>
		<link>http://www.dogcatfishdish.com/blog/?p=109</link>
		<comments>http://www.dogcatfishdish.com/blog/?p=109#comments</comments>
		<pubDate>Wed, 06 Oct 2010 11:10:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.dogcatfishdish.com/blog/?p=109</guid>
		<description><![CDATA[..No, not a cheap rip-off of Blackhawk Down, but a badly named port of the highly useful lightweight markup Markdown. In reality it’s a direct translation of the JavaScript version Showdown. The initial reason for this port is for an internal content editing tool I&#8217;m developing. I want to provide it as an alternative along [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D109"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D109&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>..No, not a cheap rip-off of Blackhawk Down, but a badly named port of the highly useful lightweight markup <a title="Markdown" href="http://daringfireball.net/projects/markdown/" target="_blank">Markdown</a>. In reality it’s a direct translation of the JavaScript version <a title="Showdown" href="http://attacklab.net/showdown/" target="_blank">Showdown</a>.</p>
<p>The initial reason for this port is for an internal content editing tool I&#8217;m developing. I want to provide it as an alternative along side the Flex <a title="RichTextEditor" href="http://livedocs.adobe.com/flex/3/html/help.html?content=textcontrols_10.html" target="_blank">RichTextEditor</a> control for fast content writing.</p>
<p>It&#8217;s at a very early stage at the moment &#8211; it&#8217;s more of a proof of concept working version. There are no optimisations and adaptations for Actionscript right now and it&#8217;s frankly quite ropey (look at those lovely ..rest parameters). Lot&#8217;s of changes and updates will follow. It&#8217;s also built as a static utility-type class which will change in the future. I just wanted to get it out there now.</p>
<p>Please have a look at <a title="Actiondown Github site" href="http://github.com/bbeaumont/Actiondown" target="_blank">Actiondown</a> on GitHub and feel free to make rude comments about the name.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D109&amp;title=Actiondown%21" id="wpa2a_12"><img src="http://www.dogcatfishdish.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.dogcatfishdish.com/blog/?feed=rss2&#038;p=109</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ant and mxmlc problem</title>
		<link>http://www.dogcatfishdish.com/blog/?p=97</link>
		<comments>http://www.dogcatfishdish.com/blog/?p=97#comments</comments>
		<pubDate>Wed, 22 Sep 2010 22:00:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Ant]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[mxmlc]]></category>

		<guid isPermaLink="false">http://www.dogcatfishdish.com/blog/?p=97</guid>
		<description><![CDATA[Today I encountered an odd issue using Ant and mxmlc, something I thought would be worth sharing to avoid pain for others. I was compiling projects using Ant within Flash Builder. I built most of them with no problems, except for one which just wouldn&#8217;t work. Rather than throw an error to give me some [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D97"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D97&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Today I encountered an odd issue using Ant and mxmlc, something I thought would be worth sharing to avoid pain for others. I was compiling projects using Ant within Flash Builder. I built most of them with no problems, except for one which just wouldn&#8217;t work. Rather than throw an error to give me some steer it just sat there and did nothing, hanging on the &#8216;Loading configuration file&#8230;&#8217; message.<br />
I eventually figured out it had something to do with embedding images using the [Embed] metatag. It didn&#8217;t matter what image or where, it would just stop working. Take out the Embed and it would compile fine.  I tried compiling it using the normal Flash Builder setup and that also worked.<br />
After searching the internet I found no similar issues reported, the nearest was references to java heap size and adding in JRE VM arguments. Even though I didn&#8217;t think it was this as I got no memory errors I thought I&#8217;d give it a go anyway.<br />
I opened the ant Build Configuration and then the JRE tab to add in the VM arguments and noticed instead that for reasons unknown it was using JVM version 1.4. That didn&#8217;t sound right to me so I changed it to 1.6 and it, you&#8217;ve guessed it, compiled fine.</p>
<p>How annoying that was.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D97&amp;title=Ant%20and%20mxmlc%20problem" id="wpa2a_14"><img src="http://www.dogcatfishdish.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.dogcatfishdish.com/blog/?feed=rss2&#038;p=97</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finger painting</title>
		<link>http://www.dogcatfishdish.com/blog/?p=84</link>
		<comments>http://www.dogcatfishdish.com/blog/?p=84#comments</comments>
		<pubDate>Fri, 02 Apr 2010 22:38:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Motion tracking]]></category>

		<guid isPermaLink="false">http://www.dogcatfishdish.com/blog/?p=84</guid>
		<description><![CDATA[Heres a fun little adaptation on the motion detection work I did before. You&#8217;ll need a webcam for it to work, and wait a few seconds for the camera to activate and setup. It&#8217;s created using the same base as the initial work I did. Every frame it randomly tests 100 or so pixels &#8211; [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D84"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D84&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Heres a fun little adaptation on the motion detection work I did before. You&#8217;ll need a webcam for it to work, and wait a few seconds for the camera to activate and setup.</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_1" width="450" height="338" align="center">
      <param name="movie" value="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/04/MotionDetection.swf" />
      <param name="align" value="center" />
      <param name="allowfullscreen" value="true" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/04/MotionDetection.swf" width="450" height="338" align="center" allowfullscreen="true">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p>It&#8217;s created using the same base as the initial work I did. Every frame it randomly tests 100 or so pixels &#8211; if they are white (motion) it draws a circle, if black (no motion) it does nothing. These are then drawn onto another bitmap, which is blurred every frame, to give the fading blurred trail effect. I also apply a random color transform every few seconds which gives it the trippy look.</p>
<p>Ok, so it&#8217;s not really finger painting, more like &#8216;flail-around-like-a-fool&#8217; painting, but at least your hands are paint free.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D84&amp;title=Finger%20painting" id="wpa2a_16"><img src="http://www.dogcatfishdish.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.dogcatfishdish.com/blog/?feed=rss2&#038;p=84</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The world in motion</title>
		<link>http://www.dogcatfishdish.com/blog/?p=70</link>
		<comments>http://www.dogcatfishdish.com/blog/?p=70#comments</comments>
		<pubDate>Tue, 02 Mar 2010 00:29:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Motion tracking]]></category>

		<guid isPermaLink="false">http://www.dogcatfishdish.com/blog/?p=70</guid>
		<description><![CDATA[Continuing my recent posts of various experments, here is a little experiement about motion tracking and using a webcam (or any digital video camera). Admittedly there is nothing fantastically new here, it&#8217;s just my interpretation of a common approach. I got the gist of it from a description on the Flash Game programming course mentioned in [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D70"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D70&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Continuing my recent posts of various experments, here is a little experiement about motion tracking and using a webcam (or any digital video camera). Admittedly there is nothing fantastically new here, it&#8217;s just my interpretation of a common approach. I got the gist of it from a description on the <a href="http://sebleedelisle.com/training/" target="_blank">Flash Game programming course</a> mentioned in previous posts, and decided to have a go at making it from scratch without reference to other sources.</p>
<p>It relys on comparing the difference between two bitmap snapshots of a video &#8211; one from the current frame, the other from the previous frame. These two images are combined using a difference blend mode which, as the name suggests, highlights the difference between two bitmaps. In this case the only difference is what moved between the two frames.</p>
<div id="attachment_76" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/03/difference.jpg" rel="lightbox[70]"><img class="size-medium wp-image-76" title="difference" src="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/03/difference-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">Difference blend mode</p></div>
<p>Once we&#8217;ve got the difference a bit of blurring is added to take out the background noise. Also, the contrast is increased to make the movement stand out a bit more.</p>
<p>The final stage is to threshold this image. Each pixel colour value is tested; if it&#8217;s above a certain level it&#8217;s converted to white, below the level it&#8217;s turned to black.</p>
<div id="attachment_77" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/03/threshold.jpg" rel="lightbox[70]"><img class="size-medium wp-image-77" title="threshold" src="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/03/threshold-300x225.jpg" alt="" width="300" height="225" /></a><p class="wp-caption-text">Threshold</p></div>
<p>Although this isn&#8217;t the most exciting looking thing in the world, it&#8217;s the foundation for lots of interesting things. It&#8217;s not too much extra work to find out the direction and speed of movement. I&#8217;ve already started using it in some pretty fun and interesting ways, which I&#8217;m sure will be the subject of a future post.</p>
<p>Below is the final working version, just click the &#8216;Allow&#8217; button to let it use the camera, then wait a few seconds and wave furiously at the camera. If it doesn&#8217;t work, please believe it&#8217;s not a way to make you look like a fool madly waving at your computer. Or is it?&#8230;</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_2" width="400" height="300" align="center">
      <param name="movie" value="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/03/MotionDetection.swf" />
      <param name="align" value="center" />
      <param name="allowfullscreen" value="true" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/03/MotionDetection.swf" width="400" height="300" align="center" allowfullscreen="true">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D70&amp;title=The%20world%20in%20motion" id="wpa2a_18"><img src="http://www.dogcatfishdish.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.dogcatfishdish.com/blog/?feed=rss2&#038;p=70</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Let&#8217;s Play!</title>
		<link>http://www.dogcatfishdish.com/blog/?p=42</link>
		<comments>http://www.dogcatfishdish.com/blog/?p=42#comments</comments>
		<pubDate>Sat, 20 Feb 2010 14:34:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.dogcatfishdish.com/blog/?p=42</guid>
		<description><![CDATA[A couple of weeks ago I attended the rather good Flash Game Training course in Brighton, run by Seb Lee-Delisle. Over the two days it covered most aspects of Flash game programming you&#8217;d expect using lots of examples. Along with being a highly useful course, there were a couple of aspect that really stood out [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D42"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D42&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>A couple of weeks ago I attended the rather good Flash Game Training course in Brighton, run by <a href="http://sebleedelisle.com/" target="_blank">Seb Lee-Delisle</a>. Over the two days it covered most aspects of Flash game programming you&#8217;d expect using lots of examples. Along with being a highly useful course, there were a couple of aspect that really stood out to me, which are more to do with a way of thinking than specific technical details.</p>
<h4>I&#8217;m with &#8216;Keep it simple, stupid&#8217;</h4>
<p>One was a simple rule for making anything &#8211; don&#8217;t over complicate things. Even though there may a &#8216;perfect&#8217; way of creating or solving something, it doesn&#8217;t necessarily make it the best solution. A lot of the time using a lateral approach is far more practical, though it&#8217;s easy to forget this.</p>
<p>In the modern warfare that is Flash we are armed with batteries of  application frameworks and platoons of unit tests. These are fantastially useful additions to our arsenal, but are often overkill and even restrictive in small applications, especially games. Having the freedom to play and experiment are essential to creating novel game experiences, a bit like going&#8230;</p>
<h4>Back 2 School</h4>
<p>After the course, I had a rush of playful energy. Playing around making games was like going back to my first encounters with Flash, when I was bombarded by crazy experiments, cool arty projects, and lots of other visual orgies. It&#8217;s been really refreshing to not to think of practicallities, or whether what I make has any real-world uses. It&#8217;s like doing letterpress work after years of InDesign or pencil drawing after knocking out Photoshop icons. It&#8217;s the reason I got into all this in the first place.</p>
<p>Although not a strict rule, I&#8217;m trying to complete each of these experiments within a few hours, just to keep the pace up. It&#8217;s too easy to start fiddling with code, or try to make it into an overly open tool or utility. So far I&#8217;ve kept up the energetic pace, and produced a fair few experiments, which I&#8217;m going to post over the next few weeks.</p>
<h4>ASCII Webcam</h4>
<p>First up is a classic ASCII art. Hardly original, but still fun to do. Rather than just a static image, I applied to a web-cam feed. Heres what it looks like, just click to &#8216;Allow&#8217; button.<br />

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_3" width="450" height="338" align="center">
      <param name="movie" value="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/02/AsciiWebCam.swf" />
      <param name="align" value="center" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://www.dogcatfishdish.com/blog/wp-content/uploads/2010/02/AsciiWebCam.swf" width="450" height="338" align="center">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>
</p>
<p>To achieve this I created an AsciiConverter class. It can take any input <code>BitmapData </code>object and convert it into an output <code>BitmapData </code>object. This means it can be used for any application using bitmaps, including video. Here&#8217;s the usage with the web-cam.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
AsciiConverter(input:BitmapData,
			output:BitmapData,
			charSize:int = 10,
			characters:Array = null,
			brightnessValues:Array = null,
			font:String = '_sans', isBold:Boolean = false)
*/</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">//Get the camera</span>
	<span style="color: #0066CC;">camera</span> = <span style="color: #0066CC;">Camera</span>.<span style="color: #006600;">getCamera</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0066CC;">camera</span>.<span style="color: #0066CC;">setMode</span><span style="color: #66cc66;">&#40;</span>CAM_WIDTH, CAM_HEIGHT, <span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span>;	
&nbsp;
	<span style="color: #808080; font-style: italic;">//Create a Video object</span>
	<span style="color: #0066CC;">video</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Video</span><span style="color: #66cc66;">&#40;</span>CAM_WIDTH, CAM_HEIGHT<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #0066CC;">video</span>.<span style="color: #006600;">attachCamera</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">camera</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">//inputData holds the video data</span>
	inputData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>CAM_WIDTH, CAM_HEIGHT, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #808080; font-style: italic;">//outputData holds the processed data</span>
	outputData = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>CAM_WIDTH, CAM_HEIGHT, <span style="color: #000000; font-weight: bold;">false</span>, 0xFFFFFF<span style="color: #66cc66;">&#41;</span>;
	outputBitmap = <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span>outputData<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	addChild<span style="color: #66cc66;">&#40;</span>outputBitmap<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">//create the AsciiConverter</span>
	asciiConverter = <span style="color: #000000; font-weight: bold;">new</span> AsciiConverter<span style="color: #66cc66;">&#40;</span>inputData, outputData, <span style="color: #cc66cc;">8</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'O'</span>, <span style="color: #ff0000;">'~'</span>, <span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\'</span>'</span>, <span style="color: #ff0000;">' '</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">230</span>, <span style="color: #cc66cc;">128</span>, <span style="color: #cc66cc;">64</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #ff0000;">'Verdana'</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">//update every frame</span>
	addEventListener<span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">ENTER_FRAME</span>, loop<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> loop<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">//this runs every few seconds to set the stage fromaeRate to the camera, which</span>
	<span style="color: #808080; font-style: italic;">//helps to make it run smooth.</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>count++ <span style="color: #66cc66;">%</span> <span style="color: #cc66cc;">60</span> == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">frameRate</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">camera</span>.<span style="color: #0066CC;">currentFPS</span> <span style="color: #66cc66;">&amp;</span>lt;= <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span> ? <span style="color: #cc66cc;">10</span> : <span style="color: #0066CC;">camera</span>.<span style="color: #0066CC;">currentFPS</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>;
&nbsp;
	outputData.<span style="color: #006600;">lock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">//draw the video to the input</span>
	inputData.<span style="color: #006600;">draw</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">video</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">//update the converter</span>
	asciiConverter.<span style="color: #006600;">update</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	outputData.<span style="color: #006600;">unlock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>I&#8217;ve put up the <a href="http://code.google.com/p/misterbenn/source/browse/trunk/com/dogcatfishdish/utils/AsciiConverter.as" target="_blank">code for the AsciiConverter</a> up on my Google Code site, which I&#8217;ll get round to commenting properly. It&#8217;s a pretty fast method for doing this. It comfortably runs at 20fps on my PC, which is the maximum frame rate of the camera.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.dogcatfishdish.com%2Fblog%2F%3Fp%3D42&amp;title=Let%E2%80%99s%20Play%21" id="wpa2a_20"><img src="http://www.dogcatfishdish.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.dogcatfishdish.com/blog/?feed=rss2&#038;p=42</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

