<?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>Turing tarpit &#187; Actionscript</title>
	<atom:link href="http://www.turingtarpit.com/category/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.turingtarpit.com</link>
	<description>Where everything is possible but nothing of interest is easy –Alan Perlis</description>
	<lastBuildDate>Thu, 11 Mar 2010 02:01:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The tweetcoding learning experience</title>
		<link>http://www.turingtarpit.com/2009/03/the-tweetcoding-learning-experience/</link>
		<comments>http://www.turingtarpit.com/2009/03/the-tweetcoding-learning-experience/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 06:48:48 +0000</pubDate>
		<dc:creator>Chandima Cumaranatunge</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[game balance]]></category>
		<category><![CDATA[gameplay]]></category>
		<category><![CDATA[micro blogging]]></category>
		<category><![CDATA[social networks]]></category>
		<category><![CDATA[tweetcoding]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.turingtarpit.com/?p=65</guid>
		<description><![CDATA[I quickly became <span style="text-decoration: line-through;">interested in</span> addicted to Grant Skinner's genius idea: <em>tweetcoding</em>. What is it? It's a programming challenge where you try to develop "something cool" using Actionscript in 140 characters. What can you learn form 140 chars? Quite a bit actually. When the compiler strict mode is off, some very interesting shortcuts are possible. There was a different group learning dynamic that was quite interesting.]]></description>
			<content:encoded><![CDATA[<p>I quickly became <span style="text-decoration: line-through;">interested in</span> <ins>addicted to</ins> Grant Skinner&#8217;s genius idea: <em>tweetcoding</em>. What is it? It&#8217;s a programming challenge where you try to develop &#8220;something cool&#8221; using Actionscript in 140 characters. The 140 chars are a hard limit as you have to submit your code via a tweet.</p>
<p>The &#8220;something cool&#8221; should be taken literally. In this first go-around, the judging criteria was decided after the submission deadline. This reminded me of Seth Godin&#8217;s <a href="http://www.amazon.com/gp/product/1591842336/103-5805607-3547849?ie=UTF8&amp;tag=chandimcumara-20&amp;linkCode=xm2&amp;camp=1789&amp;creativeASIN=1591842336" target="_blank">Tribes</a> where a tribe leader doesn&#8217;t need to have every detail ironed out. Grant just threw out the idea with some &#8220;gimme&#8221; code,  got the heck out of the way and watched wonderful things happen.</p>
<p>The initial <a href="http://gskinner.com/playpen/tweetcoding.html" target="_blank">rules</a> were all we had to begin with. However, things got really interesting after Robert Cadena developed the tweetcoding integrator at <a href="http://tweetcoding.machine501.com" target="_blank">http://tweetcoding.machine501.com</a>. This page lists all the #tweetcoding tweets with the code submissions compiled into SWFs.  Now we could look at everyone&#8217;s submissions, run the apps on the browser ( as opposed to copying and pasting each into a .fla ) and learn some new tricks ( as well as some bad programming habits ).</p>
<a name="wptoc_0_0_0"></a><h4>What can you learn form 140 chars?</h4>
<p>Quite a bit actually. When the compiler <em>strict mode</em> is off, some very interesting shortcuts are possible. For me, the big ideas were the most interesting as opposed to the little coding efficiencies discovered during the process. Don&#8217;t get me wrong, trying to figure out the best way to implement a loop in the smallest number of characters is a very interesting challenge. However, there was a different group learning dynamic that was more interesting.</p>
<p>I think we spent as much time looking at each others&#8217; submissions and learning new ways of doing things as we did coding our own submissions. Now that submissions have closed, it was cool to take a step back and see how the applications evolved over time as folks learned new techniques from each other.</p>
<a name="wptoc_0_0_1"></a><h4><strong>Learning happened in big leaps</strong></h4>
<p>When you start from the <a href="http://tweetcoding.machine501.com" target="_blank">early entries</a> at the bottom of the page and work your way up it provides an insight into the <em><strong>evolution of collective thought of a learning community</strong></em>. Learning happened, not in incremental steps, but in sudden leaps as  innovative implementations were submitted.</p>
<p>For example, the first few submissions were non-interactive circles and line drawings built on top of Grant&#8217;s first example. Then <a href="http://twitter.com/mikeysee" target="_blank">@mikeysee</a> (Michael Cann) started to use the mouse coordinates. There were a couple of submissions that used mouse coordinates after that. Then there was a stage where folks started to experiment with color. And so it went, with each new innovation or technique adopted by subsequent submissions.</p>
<p>Some of the big learning leaps that come to mind are: Using the Flash 10 3D parameters (cheap motion), using Bitmaps to draw display objects (less code). using Fill interference (cheap visual complexity) ,  cheap particle motion,  using perlin noise, generating audio etc. When I say cheap, I mean an efficient minimalist way of doing something in as few characters as possible.</p>
<a name="wptoc_0_0_2"></a><h4>Settling into comfort zones</h4>
<p>After a while. the episodic learning leaps were not as visible as more and more developers joined in and settled into their comfort zones. Most developers settled on an idea or technique and churned out a few submissions based on that. They then moved onto another technique.</p>
<p>However, there were exceptions like <a href="http://twitter.com/quasimondo" target="_blank">@quasimondo</a> (Mario Klingemann) who churned out an <a href="http://www.quasimondo.com/archives/000686.php" target="_blank">incredible array of eclectic stuff</a> in rapid sequence.</p>
<p>Now the community had more depth with novices and experts with good grasp of mathematics and trigonometry joining in and submitting some really fresh stuff.</p>
<a name="wptoc_0_0_3"></a><h4>My personal learning experience ( described in terms of comfort zones )</h4>
<p>I initially started by trying to create &#8220;something cool&#8221; as that was the only critera that was out there. I remembered a <a href="http://www.gotoandlearn.com/" target="_parent">screencast by Lee Brimelow</a> on some interesting visual effects created with repeated application of  Filters to a BitmapData object. I believe he repeatedly applied the blur and scroll filters to creat an effect like fire. It was an interesting technique in that you draw something on stage and then draw what is on stage onto a transparent BitmapData object with filters and matrix transformations.</p>
<a name="wptoc_0_0_4"></a><h4>Zone 1: Make it colorful and interesting using BitmapData scrolling</h4>
<p>During these early stages I was just trying to get my foot in the door. No great inspirational ideas, just try to make &#8220;something cool.&#8221; However much I tried, I just couldn&#8217;t keep anything that had a blur filter within 140 chars. So, it had to be something that just had scrolling and color. So that was my first comfort zone.</p>
<a name="wptoc_4_1_0"></a><h5>Line scroller</h5>
<p>My first submission was &#8220;Line Scroller&#8221;<strong> </strong>which was very leaky.  The following bug-free version was submitted later. Something I learned in this first submission was a minimalist way to choose a random color.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #004993;">b</span>=<span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">550</span>,<span style="color: #000000; font-weight:bold;">400</span>,<span style="color: #000000; font-weight:bold;">1</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>;addChild<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">b</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span>;
ls<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">5</span>,r<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span>1.67e7<span style="color: #000000;">&#41;</span>;lt<span style="color: #000000;">&#40;</span><span style="color: #004993;">mouseX</span>,<span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span>;b.<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;b.<span style="color: #004993;">scroll</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">8</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p><a title="Line Scroller" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/scroll.swf" target="_blank"><img class="alignnone size-full wp-image-39" title="click_to_open_btn" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/click_to_open_btn.jpg" alt="click_to_open_btn" width="101" height="34" /></a></p>
<a name="wptoc_4_1_1"></a><h5>Paint Spill</h5>
<p>Paint Spill is very similar to the line scroller in that it followed the same principle of scrolling. I experimented with bit shifting to choose a random set of  colors in this submission.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">!</span>i<span style="color: #000000; font-weight: bold;">?</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">b</span>=<span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span>i=<span style="color: #000000; font-weight:bold;">550</span>,i<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>ls<span style="color: #000000;">&#40;</span>r<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">9</span>,r<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span>1e7<span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">&amp;</span>lt;mouseX<span style="color: #000000;">&#41;</span>;
mt<span style="color: #000000;">&#40;</span>o.<span style="color: #004993;">x</span>=r<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span>i,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>;lt<span style="color: #000000;">&#40;</span>o.<span style="color: #004993;">x</span>,<span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">b</span>.<span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;b.<span style="color: #004993;">scroll</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p><a title="Paint Spill" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/paintspill.swf" target="_blank"><img class="alignnone size-full wp-image-39" title="click_to_open_btn" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/click_to_open_btn.jpg" alt="click_to_open_btn" width="101" height="34" /></a></p>
<a name="wptoc_0_0_5"></a><h4>Zone 2: Make it interactive using mouse input</h4>
<p>I tried to have some user interaction in all my submissions. I really liked some of the self-running submissions that drew some amazing recursive shapes with 3D transformations. However, that wasn&#8217;t my comfort zone. I decided to concentrate on giving the user some control to draw &#8220;something cool.&#8221;</p>
<p>The mouse was the cheapest way to record user input and make things interactive. Recording mouse coordinates were very cheap as you can directly access the MouseX and MouseY globals. Intercepting mouse clicks, mouse downs and mouse up were very expensive as they require event handlers.</p>
<p>I was awestruck when the first submission that recorded microphone input came along. Here was another input method that we don&#8217;t usually think about.</p>
<p>My next submission was a painting program. The first &#8220;painting&#8221; type submission was by <a href="http://twitter.com/Scarybug" target="_blank">@scarybug</a>. I went a little further by allowing the user to choose from a set of 10 colors by repeated mouse clicks. This includes something I learned from another submission: You can call a function by  using only its function name ( without the parentheses ) if you just want the default values for its arguments.</p>
<a name="wptoc_5_1_0"></a><h5>Circle Paint</h5>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">t=<span style="color: #990000;">'mouse'</span>;l=<span style="color: #004993;">stage</span>.<span style="color: #004993;">addEventListener</span>;
l<span style="color: #000000;">&#40;</span>t<span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">'Down'</span>,<span style="color: #339966; font-weight: bold;">function</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>ls<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">9</span>,1.67e7<span style="color: #000000; font-weight: bold;">*</span>s<span style="color: #000000;">&#40;</span>m.<span style="color: #004993;">PI</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000; font-weight: bold;">++%</span>10<span style="color: #000000; font-weight: bold;">+</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>;
g.<span style="color: #004993;">drawCircle</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">mouseX</span>,<span style="color: #004993;">mouseY</span>,<span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span>;l<span style="color: #000000;">&#40;</span>t<span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">'Up'</span>,ls<span style="color: #000000;">&#41;</span>;</pre></div></div>

<p><a title="Circle Paint" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/paint.swf" target="_blank"><img class="alignnone size-full wp-image-39" title="click_to_open_btn" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/click_to_open_btn.jpg" alt="click_to_open_btn" width="101" height="34" /></a></p>
<p>I couldn&#8217;t resist including a little masterpiece drawn with a 140 char paint program.</p>
<p><img class="alignnone size-medium wp-image-87" title="Drawn with Circle Paint" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/2645760-300x218.jpg" alt="Drawn with Circle Paint" width="300" height="218" /></p>
<a name="wptoc_0_0_6"></a><h4>Zone 3: Make it play worthy using casual gaming concepts</h4>
<p>Building on my effort to make things interactive, I decided to concentrate exclusively on games. In 140 characters you can only do so much in terms of gameplay.</p>
<p>The first issue was what can be sacrificed without harming the overall experience. The first to go was the winning condition. I couldn&#8217;t waste precious characters in a game loop that checks to see if the player has won. Winning had to be visual and obvious to the player. For example, if you kill all the aliens, you win. If you drop the ball, you lose.</p>
<p>The next issue was the instructions. These had to go on a separate tweet. The other aspect was to develop 140 char backstory to develop motivation to play. If you thought coding a game in 140 chars was hard, try to write a backstory or game instructions in 140 chars.</p>
<p>Developing games in 140 chars is hard! The key is to figure out quickly if an idea is going to work or not. If not, go onto something else or try a variation. For example, the Juggle submission initially started out as a &#8220;Bubble Wrap&#8221; game. It then moved into a balloon popping game before finally settling into the ball juggler.</p>
<p>Most of the unique features were encountered by pure chance and included. For example, the ball disappearing off the top of the stage when volleyed just happened while I was balancing game parameters. I could see that it added to the gameplay by introducing an additional challenge of predicting where the ball would appear next.</p>
<p>My final three submissions were all games.</p>
<a name="wptoc_6_1_0"></a><h5>The Horde</h5>
<p>Lame backstory:</p>
<p style="padding-left: 30px;">Kill one and another takes its place. The only option is to give up and let em through. Or you will go insane!!!</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span><span style="color: #000000;">&#40;</span>a <span style="color: #0033ff; font-weight: bold;">in</span> o<span style="color: #000000;">&#41;</span>a.<span style="color: #004993;">y</span><span style="color: #000000; font-weight: bold;">+</span>=s<span style="color: #000000;">&#40;</span>a.<span style="color: #004993;">x</span><span style="color: #000000;">&#41;</span>,a.<span style="color: #004993;">hitTestPoint</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">mouseX</span>,<span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">?</span>a.<span style="color: #004993;">y</span>=<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span>;
<span style="color: #000000; font-weight: bold;">++</span>i<span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight:bold;">50</span><span style="color: #000000; font-weight: bold;">?</span><span style="color: #000000;">&#40;</span>o<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>=<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Bitmap</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">9</span>,<span style="color: #000000; font-weight:bold;">9</span>,<span style="color: #000000; font-weight:bold;">0</span>,<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">x</span>=r<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000; font-weight:bold;">550</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #000000; font-weight:bold;">0</span></pre></div></div>

<p><a title="The Horde" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/horde.swf" target="_blank"><img class="alignnone size-full wp-image-39" title="click_to_open_btn" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/click_to_open_btn.jpg" alt="click_to_open_btn" width="101" height="34" /></a></p>
<a name="wptoc_6_1_1"></a><h5>Juggle</h5>
<p>Instructions:</p>
<p style="padding-left: 30px;">Use mouse pointer to volley the ball. How many times can you volley before it falls?</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>i<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>p=u=v=a=.1;q=<span style="color: #000000; font-weight:bold;">99</span>;i=m.<span style="color: #004993;">pow</span><span style="color: #000000;">&#125;</span>
<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>i<span style="color: #000000;">&#40;</span>q<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000;">&#40;</span>m=<span style="color: #004993;">mouseX</span><span style="color: #000000;">&#41;</span>,<span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">+</span>i<span style="color: #000000;">&#40;</span>p<span style="color: #000000; font-weight: bold;">-</span><span style="color: #004993;">mouseY</span>,<span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight:bold;">400</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>v=<span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">9</span>;u=q<span style="color: #000000; font-weight: bold;">-</span>m<span style="color: #000000;">&#125;</span>
v<span style="color: #000000; font-weight: bold;">+</span>=a;p<span style="color: #000000; font-weight: bold;">+</span>=v;q<span style="color: #000000; font-weight: bold;">+</span>=u<span style="color: #000000; font-weight: bold;">*</span>.25;g.<span style="color: #004993;">clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;ls<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span>;g.<span style="color: #004993;">drawCircle</span><span style="color: #000000;">&#40;</span>q,p,<span style="color: #000000; font-weight:bold;">20</span><span style="color: #000000;">&#41;</span></pre></div></div>

<p><a title="Juggle" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/juggle.swf" target="_blank"><img class="alignnone size-full wp-image-39" title="click_to_open_btn" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/click_to_open_btn.jpg" alt="click_to_open_btn" width="101" height="34" /></a></p>
<a name="wptoc_6_1_2"></a><h5>Guess the Number</h5>
<p>Instructions:</p>
<p style="padding-left: 30px;">Guess the number between 0 and 99 inclusive. Move to mouseY=0 (off top of stage) to guess (2nd num). &gt; &lt; = shows if it&#8217;s too high, low or just right!</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span>i<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>t=<span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">TextField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.<span style="color: #004993;">y</span>=p=<span style="color: #000000; font-weight:bold;">99</span>;i=<span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span>r<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span>p<span style="color: #000000;">&#41;</span>; g=<span style="color: #004993;">c</span>=<span style="color: #990000;">''</span><span style="color: #000000;">&#125;</span>
a=<span style="color: #004993;">int</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">mouseX</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000;">&#41;</span>;
<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight: bold;">!</span><span style="color: #004993;">mouseY</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>g=a;g<span style="color: #000000; font-weight: bold;">&amp;</span>gt;i<span style="color: #000000; font-weight: bold;">?</span><span style="color: #004993;">c</span>=<span style="color: #990000;">'&amp;gt;'</span><span style="color: #000000; font-weight: bold;">:</span>g<span style="color: #000000; font-weight: bold;">&amp;</span>lt;i<span style="color: #000000; font-weight: bold;">?</span><span style="color: #004993;">c</span>=<span style="color: #990000;">'&amp;lt;'</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">c</span>=<span style="color: #990000;">'='</span><span style="color: #000000;">&#125;</span>
t.<span style="color: #004993;">text</span>=a<span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">' '</span><span style="color: #000000; font-weight: bold;">+</span>g<span style="color: #000000; font-weight: bold;">+</span><span style="color: #004993;">c</span></pre></div></div>

<p><a title="Guess the Number" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/guess.swf" target="_blank"><img class="alignnone size-full wp-image-39" title="click_to_open_btn" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/click_to_open_btn.jpg" alt="click_to_open_btn" width="101" height="34" /></a></p>
<a name="wptoc_0_0_7"></a><h4>Judging criteria</h4>
<p>Grant skinner sent this tweet yesterday:</p>
<blockquote><p>#tweetcoding will be judged on aesthetics, idea, interaction, uniqueness, &amp; code. Should have the results early next week.</p></blockquote>
<p>The criteria are pretty good with equal chance for interactive and non-interactive submissions to score well. What are my chances? I&#8217;ll probably score high on <em>idea</em> and <em>interaction</em>. Maybe in <em>uniqueness</em> as well. However, I&#8217;ve done nothing special in terms of <em>aesthetics</em> and <em>code</em>.</p>
<p>Overall it was a fun learning experience. Looking forward to the results.</p>
<a name="wptoc_0_0_8"></a><h4>Update: Results</h4>
<p><a href="http://gskinner.com/playpen/tweetcoding_0/" target="_blank">http://gskinner.com/playpen/tweetcoding_0/</a></p>
<p>&#8220;Juggle&#8221; got an honorable mention. The winning entry by <a href="http://twitter.com/tomee6" target="_blank">@tomee6 </a>was an exceptional <a href="http://gskinner.com/playpen/tweetcoding_0/tc_1267109791.swf" target="_blank">diagonal snake</a> game.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.turingtarpit.com/2009/03/the-tweetcoding-learning-experience/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PureMVC Console &#8211; Shines a light inside the MVC triad</title>
		<link>http://www.turingtarpit.com/2009/03/puremvc-console-shines-a-light-inside-the-mvc-triad/</link>
		<comments>http://www.turingtarpit.com/2009/03/puremvc-console-shines-a-light-inside-the-mvc-triad/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 22:31:38 +0000</pubDate>
		<dc:creator>Chandima Cumaranatunge</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PureMVC]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.turingtarpit.com/?p=26</guid>
		<description><![CDATA[I was checking the PureMVC website today and came across PureMVC Console developed by the good folks at Kap Lab. This is an absolutely invaluable tool to figure out in real-time what is going on inside the Flex PureMVC framework in a running application.]]></description>
			<content:encoded><![CDATA[<p>I was checking the <a href="http://puremvc.org/">PureMVC</a> website today and came across <a href="http://lab.kapit.fr/display/puremvcconsole/PureMVC+Console">PureMVC Console</a> developed by the good folks at <a href="http://lab.kapit.fr/display/kaplabhome/Home">Kap Lab</a>. This is an absolutely invaluable tool to figure out in real-time what is going on inside the Flex PureMVC framework in a running application. PureMVC is quite lightweight and is very good at keeping things hidden under the hood. However, during development it is essential to get a snapshot of application state and the sequence of notifications. This is exactly what PureMVC Console does. It provides you with a flashlight to peer into your Notifications, Commands, Mediators and Proxies and track notifications and application flow in response to user gestures and other events.</p>
<div>
<p>For example, if you need to know the state of your <em>value objects</em> at any point, just click on the <em>Proxies</em>tab and select the proxy.</p>
<p><a title="Inspecting the value objects inside the proxies" rel="shadowbox[PureMVC Console]" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/vos.jpg"><img class="alignnone size-medium wp-image-28" title="Inspecting the value objects inside the proxies" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/vos-300x257.jpg" alt="Inspecting the value objects inside the proxies" width="300" height="257" /></a></p>
<p>If you want to check the sequence of actions taking place in your application from startup, just click on the PureMVC flow tab. This is very useful for debugging as it provides a record of the command invocation sequence and will help answer questions like &#8220;why did this command execute before this other one?&#8221;</p>
<p><a title="Inspecting the flow of the application" rel="shadowbox[PureMVC Console]" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/flow1.jpg"><img class="alignnone size-medium wp-image-32" title="Inspecting the flow of the application" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/flow1-300x259.jpg" alt="Inspecting the flow of the application" width="300" height="259" /></a></p>
<p>I am a big fan of the <a href="http://osflash.org/xray">Xray logger</a> developed for Flash AS2 and had to try out this console right away as this is the first console with similar utility for AS3, I integrated the console into the <a href="http://trac.puremvc.org/Demo_AS3_Flex_EmployeeAdmin">Employee Admin demo</a> (developed by Cliff Hall).</p>
<a name="wptoc_0_0_0"></a><h4>Employee Admin Demo with integrated Console</h4>
<p>Click on the button below to open the Employee Admin demo. Make sure that you hit <strong>Ctrl+Alt+F6</strong> to open the console ( <strong>Alt</strong> = <strong>Option</strong> in OSX ).</p>
<p><a href="http://www.turingtarpit.com/wp-content/uploads/2009/03/employeeadmin.swf" target="_blank"><img class="alignnone size-full wp-image-39" title="click_to_open_btn" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/click_to_open_btn.jpg" alt="click_to_open_btn" width="101" height="34" /></a></p>
<a name="wptoc_0_0_1"></a><h4>Integrating the console into the <em>Employee Admin</em> Demo</h4>
<p>The console is very easy to integrate into a new or existing app &#8211; just follow the <a href="http://lab.kapit.fr/display/puremvcconsole/Integration+Guide">integration guide</a>. The ease of integration is a huge plus as it is simply injected before the application is invoked.</p>
<a name="wptoc_1_1_0"></a><h5>1. Add the PureMVC Console SWC into your library</h5>
<p>First drag-and-drop the PureMVC Console swc file into the libs folder in your Flex project. There is a different swc if you are using the multi-core version of PureMVC.</p>
<p><img class="alignnone size-full wp-image-50" title="project_files" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/project_files.jpg" alt="project_files" width="226" height="199" /></p>
<a name="wptoc_1_1_1"></a><h5>2. Add the console component into your application</h5>
<p>For an MXML app, you need to add an additional  <code>xmlns:kapit="fr.kapit.*"</code> name space attribute to the  <code>&lt;mx:Application&gt;</code> tag and then add the  <code>&lt;kapit:PureMVCConsole/&gt;</code> component before the closing <code>&lt;/mx:Application&gt;</code> tag (see <a href="http://lab.kapit.fr/display/puremvcconsole/Integration+Guide">integration guide</a>). I added this to the <code>EmployeeAdmin.mxml</code> file which is the default application for the project.</p>
<a name="wptoc_1_1_2"></a><h5>3. Add a new SwitchFacade parent class for you application facade</h5>
<p>The next step is to create a new <code>SwitchFacade</code> class and modify your application facade so that it inherits from <code>SwitchFacade</code> ( instead of the PureMVC <code>Facade</code> class ). The <code>SwitchFacade</code> class is the same for all apps and can be copied and pasted from the <a href="http://lab.kapit.fr/display/puremvcconsole/Integration+Guide">integration guide</a>. Make sure you create the <code>SwitchFacade</code> class in the same location in the folder hierarchy where you current application facade class resides. You can right click on the enclosing folder (employeeadmin in my case) and create <strong>New &gt; ActionScript Class</strong> and type in <code>SwitchFacade</code> for the class name. Now copy and paste the code.</p>
<p><img class="alignnone size-full wp-image-54" title="project_files2" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/project_files2.jpg" alt="project_files2" width="345" height="415" /></p>
<p>Injecting the  <code>SwitchFacade</code> class allows you to control the integration of the console using compiler directives as opposed to changing code when it comes time to ship the application. <code>SwitchFacade</code> extends the PureMVC <code>Facade</code> class if the <em>CONFIG::release</em> directive is set. Conversely, if the <em>CONFIG::debug</em> directive is set ( and <em>CONFIG::release</em> is unset), <code>SwitchFacade</code> extends  <code>DebugFacade</code> that has all the debug stuff required by the console.</p>
<a name="wptoc_1_1_3"></a><h5>4. Set the compiler directives</h5>
<p>To control which facade gets extended you need to add the <em>CONFIG::release</em> and <em>CONFIG::debug</em> directives in the compiler options. Right click on the <em>Project folder</em> and choose <em>properties</em> from the contextual menu. Now click on <em>Flex Compiler</em> option to add the additional compiler directives in the <em>Additional Compiler Arguments</em> field.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">-define=CONFIG::release,false -define=CONFIG::debug,true</pre></div></div>

<p><a title="Setting compiler options" rel="shadowbox[PureMVC Console]" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/compiler_options.jpg"><img class="alignnone size-medium wp-image-57" title="compiler_options" src="http://www.turingtarpit.com/wp-content/uploads/2009/03/compiler_options-300x240.jpg" alt="compiler_options" width="300" height="240" /></a></p>
<p><a title="Setting compiler options" rel="shadowbox[PureMVC Console]" href="http://www.turingtarpit.com/wp-content/uploads/2009/03/compiler_options.jpg"></a><br />
Reset the directives for the release version.</p>
<p><strong>Recap of cool features:</strong></p>
<ul>
<li>Very easy to integrate into a new or existing app.</li>
<li>Works with the standard version of Flash ( does not need the debugger version ).</li>
<li>Integration is controlled by using compiler options ( just change a compiler option for the release version ).</li>
</ul>
<p>Simple to integrate and keeps out of the way of you doing the job of coding and debugging &#8211; excellent!</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.turingtarpit.com/2009/03/puremvc-console-shines-a-light-inside-the-mvc-triad/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
