<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3" -->
<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/"
	>

<channel>
	<title>Meandering Thought</title>
	<link>http://extralongfingers.com/wordpress</link>
	<description>Actionscript, Flex, Eclipse, Digital Sound Experiments</description>
	<pubDate>Fri, 11 Sep 2009 03:59:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3</generator>
	<language>en</language>
			<item>
		<title>Hacking the Swf Version Byte</title>
		<link>http://extralongfingers.com/wordpress/?p=34</link>
		<comments>http://extralongfingers.com/wordpress/?p=34#comments</comments>
		<pubDate>Fri, 11 Sep 2009 03:59:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[actionscript bytearray flash urlstream]]></category>

		<guid isPermaLink="false">http://extralongfingers.com/wordpress/?p=34</guid>
		<description><![CDATA[I recently checked out the Spark Project repository and found myself browsing through some of the projects in the repo. I found an interesting actionscript 3 project called Forcible Loader decided to investigate. The Forcible Loader uses an atypical loading technique for a Flash Swf. Typically one would load a Flash Swf using the Loader [...]]]></description>
			<content:encoded><![CDATA[<p>I recently checked out the <a href="http://www.libspark.org/wiki/WikiStart/en" title="Spark Library" target="_blank">Spark Project</a> repository and found myself browsing through some of the projects in the repo. I found an interesting actionscript 3 project called Forcible Loader decided to investigate. The <a href="http://www.libspark.org/svn/as3/ForcibleLoader/" title="Actionscript Forcible Loader" target="_blank">Forcible Loader</a> uses an atypical loading technique for a Flash Swf. Typically one would load a Flash Swf using the Loader class, the ForcibleLoader class however uses the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLStream.html" title="Actionscript URLStream" target="_blank">URLStream</a> object. In doing so, the Forcible Loader allows for the byte level manipulation of a swf. From the code I gather its main goal is to allow for loaded swf to be interacted with as if it were a Version 9 or greater swf. I decided to run some experiments and isolate the behaviors of the Flash virtual machine after applying varying byte level manipulations. Here are my findings :Experiment 1 :
<ul>
<li>Load a Version 8 Swf with a :Loader and a :URLStream;</li>
<li>Change the version byte value from 8 to 9 of the :URLStream loaded swf.</li>
<li>Observe behavior and compare.</li>
</ul>
<p>Result
<ul>
<li>No observable visual difference</li>
<li>atypicalLoader.contentLoaderInfo.swfVersion reports 9</li>
</ul>
<p>Experiment 2 :
<ul>
<li>Load a Version 8 Swf with a :Loader and a :URLStream;</li>
<li>Change the version byte value from 8 to 14 of the :URLStream loaded swf.</li>
<li>Observe behavior and compare.</li>
</ul>
<p>Result
<ul>
<li>No observable visual difference</li>
<li>atypicalLoader.contentLoaderInfo.swfVersion reports 14</li>
</ul>
<p>Experiment 3 :
<ul>
<li>Load a Version 8 Swf with a :Loader and a :URLStream;</li>
<li>Change the version byte value from 8 to 200 of the :URLStream loaded swf.</li>
<li>Observe behavior and compare.</li>
</ul>
<p>Result
<ul>
<li>No observable visual difference</li>
<li>atypicalLoader.contentLoaderInfo.swfVersion reports 200</li>
</ul>
<p>The experiments are posted <a href="http://extralongfingers.com/swf/versionByteManipulation/versionByteExperiments/" target="_blank" title="Actionscript Version Byte Manipulation Experiments">here</a>. In each experiment a version 8 swf is loaded in realtime by a typical :Loader object and an atypical :URLStream object. The URLStream load manipulates the version byte of the swf before casting the bytes to a Loader object.Lets walk through the code that makes this magic happen :<br />
<P></p>
<pre class="actionscript">
package
{
	import flash.net.URLStream;
	import flash.net.URLRequest;
	import flash.display.Sprite;
	import flash.display.Loader;
	import flash.display.LoaderInfo;

	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.SecurityErrorEvent;
	import flash.utils.ByteArray;
	import flash.utils.Endian;
	import flash.text.TextField;

	public class ExperimentOne extends Sprite
	{
		private var stream 				: URLStream;

		private var atypicalLoaderArea 	: Sprite;
		private var typicalLoaderArea 	: Sprite;
		private var typicalLoadComplete	: Boolean = false;
		private var atypicalLoadComplete: Boolean = false;

		private var typicalLoader 		: Loader;
		private var atypicalLoader		: Loader;

		function ExperimentOne()
		{

			log("Experiment One")
			setupLayout();
			loadViaTypicalLoader();
			loadViaUrlStream();

		}

		private function setupLayout():void
		{
			log("Experiment One.setupLayout()")

			typicalLoaderArea = new Sprite();
			typicalLoaderArea.x = 0;
			atypicalLoaderArea = new Sprite();
			atypicalLoaderArea.x = 400;

			drawBounding( typicalLoaderArea );
			drawBounding( atypicalLoaderArea );
			addTextField( "<font size=\"18\">Typical :Loader load</font>", typicalLoaderArea );
			addTextField( "<font size=\"18\">Atypical :URLStream load</font>", atypicalLoaderArea);

			addChild(typicalLoaderArea);
			addChild(atypicalLoaderArea);

		}

		private function addTextField( s : String, spr : Sprite ) : void
		{
			var t : TextField = new TextField();
			t.htmlText = s;
			t.width = 200;
			spr.addChild(t);

		}

		private function drawBounding( s : Sprite):void
		{
			log("ExperimentOne.drawBounding()")

			s.graphics.lineStyle( 3, 0x0 );
			s.graphics.beginFill( 0,0);
			s.graphics.drawRect(0,0,400,300);
			s.graphics.endFill();
		}

		private function loadViaTypicalLoader() : void
		{
			log("ExperimentOne.loadViaTypicalLoader()")

			typicalLoader = new Loader();

			typicalLoaderArea.addChild(typicalLoader);
			typicalLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, typicalcompleteHandler)
			typicalLoader.load( new URLRequest("http://extralongfingers.com/swf/versionByteManipulation/ExperimentOne/ExperimentOne_Version8_BlueCircle.swf"))

		}

			private function typicalcompleteHandler(e : Event):void
			{
				log("ExperimentOne.typicalCompleteHandler()")

				typicalLoadComplete = true;
				if( typicalLoadComplete && atypicalLoadComplete) discernResults();
			}

		private function loadViaUrlStream():void
		{
			log("ExperimentOne.loadViaUrlStream()")

			stream = new URLStream();
			stream.addEventListener(Event.COMPLETE, completeHandler);
			stream.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
			stream.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
			stream.load( new URLRequest("http://extralongfingers.com/swf/versionByteManipulation/ExperimentOne/ExperimentOne_Version8_BlueCircle.swf"))

		}

		private function completeHandler(e : Event):void
		{
			log("ExperimentOne.completeHandler()")

			var swfBytes : ByteArray = new ByteArray();
			stream.readBytes(swfBytes);
			stream.close();
			swfBytes.endian = Endian.LITTLE_ENDIAN;

			updateVersion( swfBytes, 9 );
			atypicalLoader = new Loader();
			atypicalLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, atypicalcompleteHandler)

			atypicalLoader.loadBytes( swfBytes);
			atypicalLoaderArea.addChild(atypicalLoader);

		}

		private function atypicalcompleteHandler( e : Event):void
		{
			atypicalLoadComplete = true;
			if( typicalLoadComplete && atypicalLoadComplete) discernResults();

		}

			private function updateVersion( b : ByteArray, version : uint ):void
			{
				b[3] = version;
			}
		private function discernResults():void
		{
			log("ExperimentOne.discernResults()")
			var typicalLoaderInfo : LoaderInfo = typicalLoader.contentLoaderInfo;
			var atypicalLoaderInfo : LoaderInfo = atypicalLoader.contentLoaderInfo;
			trace( "typical load : SWF Version : "+String(typicalLoaderInfo.swfVersion));
			trace( "atypical load : SWF Version : "+atypicalLoaderInfo.swfVersion);

			addSwfVersionInfoText("<font size=\"18\">Swf Version contentLoaderInfo.swfVersion=

"+String(typicalLoaderInfo.swfVersion)+"</font>", typicalLoaderArea )
			addSwfVersionInfoText("<font size=\"18\">Swf Version contentLoaderInfo.swfVersion=

"+String(atypicalLoaderInfo.swfVersion)+"</font>", atypicalLoaderArea )

		}
		private function addSwfVersionInfoText( version : String, s : Sprite):void
		{
				var t : TextField = new TextField();
				t.htmlText = version;
				t.width = 400;
				t.height = 200;
				t.y = s.height;
				t.x = s.x;
				addChild( t);

		}

		private function ioErrorHandler( e : IOErrorEvent):void
		{
			log( e.toString());
		}

		private function securityErrorHandler( e : SecurityErrorEvent):void
		{
			log( e.toString());
		}

		private function log(s : String ) : void
		{
			trace( s );

		}
	}
}
</pre>
<p></P><P>function : ExperimentOne() // ConstructorThis function sets up the environment by first using the setupLayout() method to build two "bounding" Sprites. These sprites serve as the holders into which a loaded swf will be added as a child. The left bounding sprite will hold the swf loaded by the typical :Loader object and the right bounding sprite will hold the swf loaded by the atypical :URLStream object. The constructor then proceeds to initiate these two loading operations</P><P>function :setupLayout()This function builds the two bounding Sprites that will serve as holders for the :Loader loaded swf and the :URLStream loaded swf. It also appends :TextField labels via the addTextField() method.</P><P>function addTextField()This function creates a new text :TextField, sets its htmlText to the s : String parameter, and adds the :TextField as a child of the spr : Sprite parameter</P><P>function drawBounding()This function draws a bounding rectangle with dimension 400x300 in the s : Sprite parameterfunction loadViaTypicalLoader()This function creates a typicalLoader object and loads a version 8 swf from a hardcoded url.</P><P>function typicalcompleteHandler()This function fires when the typicalLoader object has finished its load of the version 8 swf. It marks the typicalLoadComplete :Boolean variable to true and checks to see whether the other atypical load has completed as well.</P><P>function loadViaUrlStream()This function creates a URLStream object and loads the same swf that was loaded in the function loadViaTypicalLoader(). The difference here is that the URLStream object will allow for byte level manipulation of the loaded swf once loading is complete. That complete handler will be where the byte level version hacking takes place</P><P>function completeHandler()This function first creates a :ByteArray and copies the bytes from the :URLStream object to the byte array. Once complete it passes this byte array to the updateVersion() method which will alter the fourth byte of the byte array. It then creates the atypicalLoader which will load the bytes of this now altered :ByteArray.</P><P>function atypicalcompleteHandler()This event handler will fire when the atypicalLoader.loadBytes( swfBytes ) operation has completed. The atypicalLoaderComplete Boolean will be set to true, and a check will run that determines whether both the typical load and the atypical load have completed.</P><P>function updateVersion()This function accept a ByteArray as its first parameter and a :uint as its second parameter. The function expects that the ByteArray being passed is a swf and sets the 4th byte of that byte array equal to the uint passed. This byte is the storage location for a swf's version.function discernResults()This function prints the contentLoaderInfo.swfVersion value for both the typical and atypically loaded swfs. Its seems that based on the results of experiment 1, 2, and 3 it is reasonable to say that this getter function reads the 4th byte of a swf directly. Questions that arise naturally and could be experimented upon further are : What happens if one loads a swf with a :URLStream, changes its version byte, loadBytes into a Loader Object, read the contentLoaderInfo.swfVersion, convert back to Byte Array, alters the 4th byte again, convert back to a :Loader object, re-access the contentLoaderInfo.swfVersion, and print the version? What happens if one sets the byte to a negative number? Is that possible ? I am going to continue along these lines and see what more I can discern regarding these and other questions.</P><P>function addSwfVersionInfoText()This function prints the swf version reported by the contentLoaderInfo.swfVersion for each :Loader object, both typical and atypical </P><P>If you have any interest in playing with this code and carrying out some of the further investigations I mentioned please feel free to git clone the code from here :</P><P>git clone git://github.com/blackberryoctopus/Actionscript-Swf-Loading-Experiments.git ./loadingExperiments</P></p>
]]></content:encoded>
			<wfw:commentRss>http://extralongfingers.com/wordpress/?feed=rss2&amp;p=34</wfw:commentRss>
		</item>
		<item>
		<title>Solving Zero Sum Game Matrices with Actionscript.</title>
		<link>http://extralongfingers.com/wordpress/?p=32</link>
		<comments>http://extralongfingers.com/wordpress/?p=32#comments</comments>
		<pubDate>Mon, 15 Dec 2008 03:40:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[algorithms]]></category>

		<category><![CDATA[game theory]]></category>

		<category><![CDATA[mathematics]]></category>

		<guid isPermaLink="false">http://extralongfingers.com/wordpress/?p=32</guid>
		<description><![CDATA[ 

I have recently been reading the book Game Theory and Strategy by Phillip Straffin.  It was suggested to me by my mathematics teacher Patroklos Benatos.  He suggested I read this book for an introduction to the study of Game Theory.  It has been excellent reading and inspired me to develop an application that aids one in [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #551a8b; font-size: 9px; line-height: 7px; text-decoration: underline" class="Apple-style-span"> </span>
<p style="text-align: center"><a href="http://www.extralongfingers.com/math/game_theory/SaddlePoint1/Gametheory_Experiment.html"><img src="http://www.extralongfingers.com/math/game_theory/SaddlePoint1/Game_Theory_Zero_Sum_Game_Solve.jpg" /></a></p>
<p><P><P>I have recently been reading the book <a href="http://www.amazon.com/gp/product/0883856379?ie=UTF8&amp;tag=extralongfing-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0883856379" target="_blank" title="Game Theory and Strategy">Game Theory and Strategy by Phillip Straffin</a>.  It was suggested to me by my mathematics teacher <a href="http://directory.skype.com/en/skypeprime/listing/patroklosb/Tutoring-in-Advanced-Math-Physics-Windows-and-English" title="Patroklos Benatos">Patroklos Benatos</a>.  He suggested I read this book for an introduction to the study of Game Theory.  It has been excellent reading and inspired me to develop an application that aids one in finding a solution to a zero sum game matrix.       So lets take a look at the code.  The constructor of the application sets up some TextFields that will be used throughout the calculation of the matrix game solution.   These text fields will be filled with the cells of the matrix that hold the largest column entry, the smallest row entry, and any saddle points present in the matrix.  A for() loop ( Line 45 ) is used to generate random entries in the cells of the matrix such that  -10&lt; n &lt; 10 where n is the payoff of that cell.  I chose a 4x4 matrix for the size of this matrix.  I am planning to allow the user to alter the <span class="Apple-style-span" style="font-style: italic"><span class="Apple-style-span" style="font-weight: bold">m</span></span>x<span class="Apple-style-span" style="font-style: italic"><span class="Apple-style-span" style="font-weight: bold">n</span></span> dimensions in a future iteration of this application, but for now the size of the generated matrix is static.  After generating  the payoffs for the 16 cells of the matrix at random the code runs the function checkForSaddlePoints().      <P><P>    The first thing performed in the execution of checkForSaddlePoints()  is the TextFields ( Line 99 ) that identify the Greatest Column Payoffs , the Least Row Payoffs, and the Saddle Points are restored to their original forms.  At this point the TextFields do not identify any entries in the matrix.  As the loops and calculations ahead in the code execute.  The for() loop ( line 110 ) begins by extracting each <span class="Apple-style-span" style="font-style: italic">key </span>from the Dictionary object.  <P><P>Each key object is a TextField which was stored in the Dictionary ( line 65 ).   The object at d[ key ] stores the column and row index for this TextField.  Now that the code has identified one TextField, its column index, and its row index, its time to start storing and the largest column and least row entries in the matrix.  The aColumn array is used to keep track of which columns have been already checked for their largest entries.  The aRow Array is used to keep track of which rows have been already  checked for their least entries. If for example a certain column has not been checked for its largest entry the code inside the if( aColumn[c] != true ) will execute ( line 120 ), in turn running the method findGreatestEntryInColumn() which evaluates every entry in this particular column <span class="Apple-style-span" style="font-style: italic">c.  </span>After identifying this entry in said column, it will be differentiated by coloring its text red.  Its entry information will also be stored on greatestColumns Array for later use when checking for the existence of saddle points.  The evaluation of if( aRow[r] != true ) works in exactly the same way ( line 132 ). After this evaluation is complete, the code can then determine if a <a href="http://en.wikipedia.org/wiki/Saddle_point">saddle point</a> is present in the matrix by checking if any of the Greatest Column entries coincide the with Least Row entries. ( line 150 ).  <P><P>    And here is the code that make this whole thing work ::  <P><P></p>
<pre class="actionscript">&nbsp;
<span class="coMULTI">/**
 * This class is the controlling entity of Game Theory Matrix Solver
 *
 * Copyright (c) 2008 Gregory Sogorka.
 */</span>
package
<span class="br0">&#123;</span>
	<span class="kw3">import</span> flash.<span class="me1">display</span>.<span class="me1">Sprite</span>;
	<span class="kw3">import</span> flash.<span class="me1">events</span>.<span class="me1">Event</span>;
	<span class="kw3">import</span> flash.<span class="kw3">text</span>.<span class="kw3">TextField</span>;
	<span class="kw3">import</span> flash.<span class="kw3">text</span>.<span class="me1">TextFieldType</span>;
	<span class="kw3">import</span> flash.<span class="me1">utils</span>.<span class="me1">Dictionary</span>;
&nbsp;
	<span class="kw3">public</span> <span class="kw2">class</span> Gametheory_Experiment <span class="kw3">extends</span> Sprite
	<span class="br0">&#123;</span>
		<span class="kw3">private</span> <span class="kw2">var</span> d 					: Dictionary;
		<span class="kw3">private</span> <span class="kw2">var</span> columnAlert 		: <span class="kw3">TextField</span>;
		<span class="kw3">private</span> <span class="kw2">var</span> rowAlert 			: <span class="kw3">TextField</span>;
		<span class="kw3">private</span> <span class="kw2">var</span> saddlePointAlert 	: <span class="kw3">TextField</span>;
		<span class="kw3">private</span> <span class="kw2">var</span> totalColumns		: <span class="kw3">int</span>;
		<span class="kw3">private</span> <span class="kw2">var</span> totalRows			: <span class="kw3">int</span>;
		<span class="kw3">private</span> <span class="kw2">var</span> xPos				: <span class="kw3">int</span> = <span class="nu0">100</span>;
&nbsp;
		<span class="kw3">public</span> <span class="kw2">function</span> Gametheory_Experiment<span class="br0">&#40;</span><span class="br0">&#41;</span>
		<span class="br0">&#123;</span>
			d = <span class="kw2">new</span> Dictionary<span class="br0">&#40;</span><span class="br0">&#41;</span>;
&nbsp;
			columnAlert 		= <span class="kw2">new</span> <span class="kw3">TextField</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
			columnAlert.<span class="me1">x</span> 		= xPos;
			columnAlert.<span class="me1">y</span> 		= <span class="nu0">20</span>;
			columnAlert.<span class="kw3">width</span> 	= <span class="nu0">350</span>;
			addChild<span class="br0">&#40;</span> columnAlert <span class="br0">&#41;</span>;
&nbsp;
			rowAlert = <span class="kw2">new</span> <span class="kw3">TextField</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
			rowAlert.<span class="me1">x</span> = xPos;
			rowAlert.<span class="me1">y</span> = <span class="nu0">40</span>;
			rowAlert.<span class="kw3">width</span> = <span class="nu0">350</span>;
			addChild<span class="br0">&#40;</span> rowAlert <span class="br0">&#41;</span>;
&nbsp;
			saddlePointAlert = <span class="kw2">new</span> <span class="kw3">TextField</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
			saddlePointAlert.<span class="me1">x</span> = xPos;
			saddlePointAlert.<span class="me1">y</span> = <span class="nu0">60</span>;
			saddlePointAlert.<span class="kw3">width</span> = <span class="nu0">350</span>;
			addChild<span class="br0">&#40;</span> saddlePointAlert <span class="br0">&#41;</span>;
&nbsp;
			<span class="kw1">for</span><span class="br0">&#40;</span> <span class="kw2">var</span> i : <span class="kw3">int</span> = <span class="nu0">0</span>; i&lt;<span class="nu0">4</span>; i++ <span class="br0">&#41;</span><span class="br0">&#123;</span>
&nbsp;
				<span class="kw1">for</span><span class="br0">&#40;</span> <span class="kw2">var</span> j : <span class="kw3">int</span> = <span class="nu0">0</span>; j&lt;<span class="nu0">4</span>; j++ <span class="br0">&#41;</span><span class="br0">&#123;</span>
&nbsp;
					<span class="kw2">var</span> t 	: <span class="kw3">TextField</span> = <span class="kw2">new</span> <span class="kw3">TextField</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
					<span class="kw2">var</span> num : <span class="kw3">Number</span> 	= <span class="kw3">Math</span>.<span class="kw3">floor</span><span class="br0">&#40;</span> <span class="kw3">Math</span>.<span class="kw3">random</span><span class="br0">&#40;</span><span class="br0">&#41;</span> * <span class="nu0">10</span> <span class="br0">&#41;</span>;
					t.<span class="kw3">text</span> 				= <span class="br0">&#40;</span> <span class="kw3">Math</span>.<span class="kw3">random</span><span class="br0">&#40;</span><span class="br0">&#41;</span> &gt; .<span class="nu0">5</span> <span class="br0">&#41;</span>?<span class="kw3">String</span><span class="br0">&#40;</span>num<span class="br0">&#41;</span>:<span class="kw3">String</span><span class="br0">&#40;</span><span class="nu0">-1</span>*num<span class="br0">&#41;</span>;
					t.<span class="kw3">border</span> 			= <span class="kw2">true</span>;
					t.<span class="kw3">borderColor</span> 		= 0x00000000;
					addChild<span class="br0">&#40;</span> t <span class="br0">&#41;</span>;
&nbsp;
					t.<span class="me1">x</span> = j*<span class="nu0">20.5</span>;
					t.<span class="me1">y</span> = i*<span class="nu0">20.5</span>;
					t.<span class="kw3">width</span> = <span class="nu0">20</span>;
					t.<span class="kw3">height</span> = <span class="nu0">20</span>;
					t.<span class="kw3">type</span> = TextFieldType.<span class="me1">INPUT</span>;
					t.<span class="me1">addEventListener</span><span class="br0">&#40;</span> Event.<span class="me1">CHANGE</span>, textChange <span class="br0">&#41;</span>;
&nbsp;
					d<span class="br0">&#91;</span>t<span class="br0">&#93;</span>=	<span class="br0">&#123;</span> row : i, column : j <span class="br0">&#125;</span>;
&nbsp;
				<span class="br0">&#125;</span>
			<span class="br0">&#125;</span>
&nbsp;
			totalColumns = j;
			totalRows = i;
&nbsp;
			checkForSaddlePoints<span class="br0">&#40;</span><span class="br0">&#41;</span>;
&nbsp;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">private</span> <span class="kw2">function</span> textChange<span class="br0">&#40;</span> <span class="kw3">e</span> : Event <span class="br0">&#41;</span> : <span class="kw3">void</span>
		<span class="br0">&#123;</span>
			checkForSaddlePoints<span class="br0">&#40;</span><span class="br0">&#41;</span>;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">private</span> <span class="kw2">function</span> getAllValuesInColumn<span class="br0">&#40;</span> i : <span class="kw3">int</span> <span class="br0">&#41;</span> : <span class="kw3">Array</span> <span class="br0">&#123;</span>
&nbsp;
			<span class="kw2">var</span> a : <span class="kw3">Array</span>= <span class="kw2">new</span> <span class="kw3">Array</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
			<span class="kw1">for</span><span class="br0">&#40;</span> <span class="kw2">var</span> <span class="kw3">key</span> : <span class="kw3">Object</span> <span class="kw1">in</span> d <span class="br0">&#41;</span> <span class="br0">&#123;</span>
				<span class="kw1">if</span><span class="br0">&#40;</span> d<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span> == i <span class="br0">&#41;</span> a.<span class="kw3">push</span><span class="br0">&#40;</span> <span class="br0">&#123;</span> column : d<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span>, row : d<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span>, value : <span class="kw3">TextField</span><span class="br0">&#40;</span> <span class="kw3">key</span> <span class="br0">&#41;</span>.<span class="kw3">text</span> <span class="br0">&#125;</span> <span class="br0">&#41;</span>; 
&nbsp;
			<span class="br0">&#125;</span>
&nbsp;
			<span class="kw1">return</span> a;
		<span class="br0">&#125;</span>
		<span class="kw3">private</span> <span class="kw2">function</span> checkForSaddlePoints<span class="br0">&#40;</span><span class="br0">&#41;</span> : <span class="kw3">void</span> <span class="br0">&#123;</span>
&nbsp;
			columnAlert.<span class="kw3">htmlText</span> 			= <span class="st0">&quot;&lt;font size='8' color='#ff0000'&gt;Greatest Column Entry&lt;/font&gt; at : &quot;</span>;
			rowAlert.<span class="kw3">htmlText</span> 				= <span class="st0">&quot;&lt;font size='8' color='#0000ff'&gt;Least Row Entry&lt;/font&gt; at : &quot;</span>;
			saddlePointAlert.<span class="kw3">htmlText</span> 		= <span class="st0">&quot;&lt;font size='8' color='#A2627A'&gt;Saddle Points&lt;/font&gt; at : &quot;</span>;
			resetTextFieldColors<span class="br0">&#40;</span><span class="br0">&#41;</span>;
&nbsp;
			<span class="kw2">var</span> aColumn 		: <span class="kw3">Array</span> = <span class="kw2">new</span> <span class="kw3">Array</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
			<span class="kw2">var</span> aRow 			: <span class="kw3">Array</span> = <span class="kw2">new</span> <span class="kw3">Array</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;		
&nbsp;
			<span class="kw2">var</span> greatestColumns : <span class="kw3">Array</span> = <span class="kw2">new</span> <span class="kw3">Array</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
			<span class="kw2">var</span> lowestRows		: <span class="kw3">Array</span> = <span class="kw2">new</span> <span class="kw3">Array</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
&nbsp;
			<span class="kw1">for</span><span class="br0">&#40;</span> <span class="kw2">var</span> <span class="kw3">key</span> : <span class="kw3">Object</span> <span class="kw1">in</span> d <span class="br0">&#41;</span>
			<span class="br0">&#123;</span>
				<span class="co1">//key is a textfield;</span>
				<span class="co1">//c is TextField( key ) column index;</span>
				<span class="co1">//r is TextField( key ) row index;</span>
				<span class="kw2">var</span> c : <span class="kw3">Number</span> 		= d<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span>;
				<span class="kw2">var</span> r : <span class="kw3">Number</span> 		= d<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span>;
				<span class="kw2">var</span> t : <span class="kw3">TextField</span> 	= <span class="kw3">TextField</span><span class="br0">&#40;</span> <span class="kw3">key</span> <span class="br0">&#41;</span>;
&nbsp;
				<span class="co1">//If we've not encountered this column before lets decide what its greatest entry is an object holding that info to o</span>
				<span class="kw1">if</span><span class="br0">&#40;</span> aColumn<span class="br0">&#91;</span>c<span class="br0">&#93;</span> != <span class="kw2">true</span> <span class="br0">&#41;</span>
				<span class="br0">&#123;</span>
					<span class="kw2">var</span> o : <span class="kw3">Object</span>    = findGreatestEntryInColumn<span class="br0">&#40;</span> c, t <span class="br0">&#41;</span>;
					<span class="co1">//Change the color of the largest column entry</span>
					getTextFieldByCoordinate<span class="br0">&#40;</span> o<span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span>, o<span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span>.<span class="kw3">textColor</span> = 0xffff0000;
					columnAlert.<span class="kw3">htmlText</span> += <span class="st0">&quot;&lt;font size='8'&gt; [&quot;</span>+o<span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span>+<span class="st0">&quot; , &quot;</span>+o<span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span> +<span class="st0">&quot;] &lt;/font&gt;&quot;</span>
					<span class="co1">//So further interations of our for() loop don't reevaluate this column</span>
					aColumn<span class="br0">&#91;</span>c<span class="br0">&#93;</span> = <span class="kw2">true</span>;
					greatestColumns.<span class="kw3">push</span><span class="br0">&#40;</span> o <span class="br0">&#41;</span>;
				<span class="br0">&#125;</span>
&nbsp;
				<span class="co1">//If we've not encountered this row before lets decide what its least entry is an object holding that info to or</span>
				<span class="kw1">if</span><span class="br0">&#40;</span> aRow<span class="br0">&#91;</span>r<span class="br0">&#93;</span> != <span class="kw2">true</span> <span class="br0">&#41;</span>
				<span class="br0">&#123;</span>
					<span class="kw2">var</span> or : <span class="kw3">Object</span> = findLowestEntryInRow<span class="br0">&#40;</span> r, t <span class="br0">&#41;</span>;
					<span class="co1">//Change the color of the lowest row entry cell.</span>
					getTextFieldByCoordinate<span class="br0">&#40;</span> or<span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span>, or<span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span>.<span class="kw3">textColor</span> = 0xff0000ff;
					rowAlert.<span class="kw3">htmlText</span> += <span class="st0">&quot;&lt;font size='8'&gt; [&quot;</span>+or<span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span>+<span class="st0">&quot; , &quot;</span>+or<span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span> +<span class="st0">&quot;] &lt;/font&gt;&quot;</span>;
&nbsp;
					aRow<span class="br0">&#91;</span>r<span class="br0">&#93;</span> = <span class="kw2">true</span>;
					lowestRows.<span class="kw3">push</span><span class="br0">&#40;</span> or <span class="br0">&#41;</span>;
				<span class="br0">&#125;</span>
&nbsp;
			<span class="br0">&#125;</span>
&nbsp;
		<span class="co1">// Basically the dimensions of our MxN matrix</span>
		<span class="kw2">var</span> cLength : <span class="kw3">int</span> = greatestColumns.<span class="kw3">length</span>;
		<span class="kw2">var</span> rLength : <span class="kw3">int</span> = lowestRows.<span class="kw3">length</span>;
&nbsp;
		<span class="kw1">for</span><span class="br0">&#40;</span> <span class="kw2">var</span> i : <span class="kw3">Number</span> =<span class="nu0">0</span>;i&lt; cLength; i++ <span class="br0">&#41;</span><span class="br0">&#123;</span>
			<span class="kw2">var</span> oCol : <span class="kw3">Object</span> = greatestColumns<span class="br0">&#91;</span>i<span class="br0">&#93;</span>;
&nbsp;
			<span class="kw1">for</span><span class="br0">&#40;</span> <span class="kw2">var</span> j : <span class="kw3">Number</span>=<span class="nu0">0</span>; j&lt; lowestRows.<span class="kw3">length</span>; j++ <span class="br0">&#41;</span>
			<span class="br0">&#123;</span>
				<span class="kw2">var</span> oRow : <span class="kw3">Object</span> = lowestRows<span class="br0">&#91;</span>j<span class="br0">&#93;</span>;
				<span class="co1">//Check if the greatest column entry is the same as any of the least row entries</span>
				<span class="kw1">if</span><span class="br0">&#40;</span> oCol<span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span> == oRow<span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span> &amp;&amp; oCol<span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span> == oRow<span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span> <span class="br0">&#41;</span>
				<span class="br0">&#123;</span>
					<span class="co1">//</span>
					saddlePointAlert.<span class="kw3">htmlText</span> += <span class="st0">&quot;&lt;font size='8'&gt; [&quot;</span>+oCol<span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span>+<span class="st0">&quot; , &quot;</span>+oCol<span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span>+<span class="st0">&quot;] &lt;/font&gt;&quot;</span>;
					<span class="co1">//Change the color of the saddle point cell to purple</span>
					getTextFieldByCoordinate<span class="br0">&#40;</span> oCol<span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span>,oCol<span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>.<span class="kw3">textColor</span>= 0xffA2627A;
				<span class="br0">&#125;</span>
			<span class="br0">&#125;</span>
		<span class="br0">&#125;</span>
&nbsp;
	<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">private</span> <span class="kw2">function</span> findLowestEntryInRow<span class="br0">&#40;</span> row : <span class="kw3">Number</span>, changed : <span class="kw3">TextField</span> <span class="br0">&#41;</span> : <span class="kw3">Object</span> <span class="br0">&#123;</span>
&nbsp;
			<span class="kw2">var</span> o : <span class="kw3">Object</span> = <span class="br0">&#123;</span> column : d<span class="br0">&#91;</span>changed<span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span>, row : d<span class="br0">&#91;</span>changed<span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span> <span class="br0">&#125;</span>;
&nbsp;
			<span class="kw2">var</span> least : <span class="kw3">Number</span>= <span class="kw3">Number</span><span class="br0">&#40;</span> changed.<span class="kw3">text</span> <span class="br0">&#41;</span>;
&nbsp;
			<span class="kw1">for</span><span class="br0">&#40;</span> <span class="kw2">var</span> <span class="kw3">key</span> : <span class="kw3">Object</span> <span class="kw1">in</span> d <span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp;
				<span class="kw1">if</span><span class="br0">&#40;</span> d<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span> == row <span class="br0">&#41;</span> <span class="br0">&#123;</span>
					<span class="kw2">var</span> t : <span class="kw3">TextField</span> 	= <span class="kw3">TextField</span><span class="br0">&#40;</span> <span class="kw3">key</span> <span class="br0">&#41;</span>;
					<span class="kw2">var</span> n : <span class="kw3">Number</span>		= <span class="kw3">Number</span><span class="br0">&#40;</span> t.<span class="kw3">text</span> <span class="br0">&#41;</span>;
&nbsp;
					<span class="kw1">if</span><span class="br0">&#40;</span> n &lt; least <span class="br0">&#41;</span><span class="br0">&#123;</span>
						least = n;
						o=  <span class="br0">&#123;</span> row : d<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span>, column : d<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span> <span class="br0">&#125;</span>;
					<span class="br0">&#125;</span>
				<span class="br0">&#125;</span>
			<span class="br0">&#125;</span>
&nbsp;
			<span class="kw1">return</span> o;
&nbsp;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">private</span> <span class="kw2">function</span> findGreatestEntryInColumn<span class="br0">&#40;</span> col : <span class="kw3">Number</span>, changed : <span class="kw3">TextField</span> <span class="br0">&#41;</span> : <span class="kw3">Object</span>
		<span class="br0">&#123;</span>
			<span class="kw2">var</span> o 			: <span class="kw3">Object</span> = <span class="br0">&#123;</span> column : d<span class="br0">&#91;</span>changed<span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span>, row : d<span class="br0">&#91;</span>changed<span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span> <span class="br0">&#125;</span>;
			<span class="kw2">var</span> greatest 	: <span class="kw3">Number</span> = <span class="kw3">Number</span><span class="br0">&#40;</span> changed.<span class="kw3">text</span> <span class="br0">&#41;</span>;
&nbsp;
			<span class="kw1">for</span><span class="br0">&#40;</span> <span class="kw2">var</span> <span class="kw3">key</span> : <span class="kw3">Object</span> <span class="kw1">in</span> d <span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp;
				<span class="kw1">if</span><span class="br0">&#40;</span> d<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span> == col <span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp;
					<span class="kw2">var</span> t : <span class="kw3">TextField</span> = <span class="kw3">TextField</span><span class="br0">&#40;</span> <span class="kw3">key</span> <span class="br0">&#41;</span>;
					<span class="kw2">var</span> n : <span class="kw3">Number</span> = <span class="kw3">Number</span><span class="br0">&#40;</span> t.<span class="kw3">text</span> <span class="br0">&#41;</span>;
&nbsp;
					<span class="kw1">if</span><span class="br0">&#40;</span> n &gt; greatest <span class="br0">&#41;</span><span class="br0">&#123;</span>
						greatest = n;
						o = <span class="br0">&#123;</span> column : d<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span>, row : d<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span> <span class="br0">&#125;</span>;
					<span class="br0">&#125;</span>
				<span class="br0">&#125;</span>
			<span class="br0">&#125;</span>
&nbsp;
			<span class="kw1">return</span> o;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">private</span> <span class="kw2">function</span> getTextFieldByCoordinate<span class="br0">&#40;</span> row : <span class="kw3">int</span>, column : <span class="kw3">int</span> <span class="br0">&#41;</span> : <span class="kw3">TextField</span> <span class="br0">&#123;</span>
&nbsp;
			<span class="kw2">var</span> t : <span class="kw3">TextField</span>;
&nbsp;
			<span class="kw1">for</span><span class="br0">&#40;</span> <span class="kw2">var</span> <span class="kw3">key</span> : <span class="kw3">Object</span> <span class="kw1">in</span> d <span class="br0">&#41;</span> <span class="br0">&#123;</span>
				<span class="kw1">if</span><span class="br0">&#40;</span> d<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;column&quot;</span><span class="br0">&#93;</span> == column &amp;&amp; d<span class="br0">&#91;</span><span class="kw3">key</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st0">&quot;row&quot;</span><span class="br0">&#93;</span> == row <span class="br0">&#41;</span> t= <span class="kw3">TextField</span><span class="br0">&#40;</span> <span class="kw3">key</span> <span class="br0">&#41;</span>;
			<span class="br0">&#125;</span>
&nbsp;
			<span class="kw1">return</span> t;
&nbsp;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">private</span> <span class="kw2">function</span> resetTextFieldColors<span class="br0">&#40;</span><span class="br0">&#41;</span> : <span class="kw3">void</span> <span class="br0">&#123;</span>
			<span class="kw1">for</span><span class="br0">&#40;</span> <span class="kw2">var</span> <span class="kw3">key</span> : <span class="kw3">Object</span> <span class="kw1">in</span> d <span class="br0">&#41;</span> <span class="br0">&#123;</span>
				<span class="kw3">TextField</span><span class="br0">&#40;</span> <span class="kw3">key</span> <span class="br0">&#41;</span>.<span class="kw3">textColor</span> =<span class="nu0">0</span>;
&nbsp;
			<span class="br0">&#125;</span>
		<span class="br0">&#125;</span>
&nbsp;
	<span class="br0">&#125;</span>
&nbsp;
	<span class="br0">&#125;</span>
&nbsp;</pre>
<p><P><P><br />
  Here is a link to the <a href="http://www.extralongfingers.com/math/game_theory/SaddlePoint1/Gametheory_Experiment.as" title="Game Theory Matrix Game Application Source Code">source code</a>.   Feel free to send me any comments, suggestions, or optimizations for this code.   Source </p>
]]></content:encoded>
			<wfw:commentRss>http://extralongfingers.com/wordpress/?feed=rss2&amp;p=32</wfw:commentRss>
		</item>
		<item>
		<title>Custom ShapeRenderer for Flare in Actionscript 3</title>
		<link>http://extralongfingers.com/wordpress/?p=25</link>
		<comments>http://extralongfingers.com/wordpress/?p=25#comments</comments>
		<pubDate>Sat, 18 Oct 2008 22:20:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://extralongfingers.com/wordpress/?p=25</guid>
		<description><![CDATA[
I've been working with the Flare visualization libraries a bunch lately and found myself wanting to use new shapes to represent nodes of a graph.  With a little research I found its possible to implement the IRenderer interface and set a custom renderer for each node.  This is a pretty simple implementation, but from it [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center"><a href="http://extralongfingers.com/wordpress/?attachment_id=27" title="RoundedBlockShapeRenderer" rel="attachment wp-att-27"><img src="http://extralongfingers.com/wordpress/wp-content/uploads/2008/10/flare_roundedblockshaperendererhtml.png" alt="RoundedBlockShapeRenderer" /></a></p>
<p>I've been working with the Flare visualization libraries a bunch lately and found myself wanting to use new shapes to represent nodes of a graph.  With a little research I found its possible to implement the IRenderer interface and set a custom renderer for each node.  This is a pretty simple implementation, but from it I think one can see the possibilities for more complex shapes / colors in data representations.  The following is the client code that sets up the graph and visits each node setting its renderer property ::</p>
<pre class="actionscript">&nbsp;
package <span class="br0">&#123;</span>
&nbsp;
	<span class="kw3">import</span> com.<span class="me1">extralongfingers</span>.<span class="me1">graphs</span>.<span class="me1">client</span>.<span class="me1">render</span>.<span class="me1">RoundBlockRenderer</span>;
	<span class="kw3">import</span> com.<span class="me1">extralongfingers</span>.<span class="me1">graphs</span>.<span class="me1">client</span>.<span class="me1">utils</span>.<span class="me1">GraphUtil</span>;
&nbsp;
	<span class="kw3">import</span> flare.<span class="me1">animate</span>.<span class="me1">Transitioner</span>;
	<span class="kw3">import</span> flare.<span class="me1">vis</span>.<span class="me1">Visualization</span>;
	<span class="kw3">import</span> flare.<span class="me1">vis</span>.<span class="kw3">data</span>.<span class="me1">NodeSprite</span>;
	<span class="kw3">import</span> flare.<span class="me1">vis</span>.<span class="kw3">data</span>.<span class="me1">Tree</span>;
	<span class="kw3">import</span> flare.<span class="me1">vis</span>.<span class="me1">operator</span>.<span class="me1">layout</span>.<span class="me1">TreeMapLayout</span>;
&nbsp;
	<span class="kw3">import</span> flash.<span class="me1">display</span>.<span class="me1">Sprite</span>;
	<span class="kw3">import</span> flash.<span class="me1">geom</span>.<span class="me1">Rectangle</span>;
&nbsp;
	<span class="kw3">public</span> <span class="kw2">class</span> Flare_RoundedBlockShapeRenderer <span class="kw3">extends</span> Sprite
	<span class="br0">&#123;</span>
		<span class="kw3">public</span> <span class="kw2">function</span> Flare_RoundedBlockShapeRenderer<span class="br0">&#40;</span><span class="br0">&#41;</span>
		<span class="br0">&#123;</span>
			_init<span class="br0">&#40;</span><span class="br0">&#41;</span>;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">private</span> <span class="kw2">function</span> _init<span class="br0">&#40;</span><span class="br0">&#41;</span> : <span class="kw3">void</span>
		<span class="br0">&#123;</span>
			<span class="kw2">var</span> t 		: Tree 			= GraphUtil.<span class="me1">balancedTree</span><span class="br0">&#40;</span><span class="nu0">12</span>,<span class="nu0">1</span><span class="br0">&#41;</span>;
			<span class="kw2">var</span> vis 	: Visualization = <span class="kw2">new</span> Visualization<span class="br0">&#40;</span> t <span class="br0">&#41;</span>;
			vis.<span class="me1">bounds</span> 					= <span class="kw2">new</span> Rectangle<span class="br0">&#40;</span><span class="nu0">0</span>,<span class="nu0">0</span>,<span class="nu0">250</span>,<span class="nu0">250</span><span class="br0">&#41;</span>;
&nbsp;
			vis.<span class="kw3">data</span>.<span class="me1">nodes</span>.<span class="me1">visit</span><span class="br0">&#40;</span> _nodeVisit <span class="br0">&#41;</span>;
&nbsp;
			<span class="kw2">var</span> _tml 	: TreeMapLayout = <span class="kw2">new</span> TreeMapLayout<span class="br0">&#40;</span> <span class="st0">&quot;size&quot;</span> <span class="br0">&#41;</span>;
			vis.<span class="me1">operators</span>.<span class="kw3">add</span><span class="br0">&#40;</span> _tml <span class="br0">&#41;</span>;
			addChild<span class="br0">&#40;</span> vis <span class="br0">&#41;</span>;
			vis.<span class="me1">update</span><span class="br0">&#40;</span> <span class="kw2">new</span> Transitioner<span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span> <span class="br0">&#41;</span>.<span class="kw3">play</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
&nbsp;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">private</span> <span class="kw2">function</span> _nodeVisit<span class="br0">&#40;</span> n : NodeSprite <span class="br0">&#41;</span> : <span class="kw3">void</span>
		<span class="br0">&#123;</span>
			n.<span class="me1">renderer</span> 	= RoundBlockRenderer.<span class="me1">instance</span>;
			n.<span class="me1">shape</span>		= RoundBlockRenderer.<span class="me1">ROUNDED_BLOCK</span>;
			n.<span class="me1">fillColor</span> = <span class="kw3">Math</span>.<span class="kw3">random</span><span class="br0">&#40;</span><span class="br0">&#41;</span> * 0xffffffff;
			n.<span class="kw3">size</span> 		= <span class="kw3">Math</span>.<span class="kw3">random</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
		<span class="br0">&#125;</span>
	<span class="br0">&#125;</span>
<span class="br0">&#125;</span>
&nbsp;</pre>
<p>And here is my implementation of a custom Renderer called RoundedBlockRenderer that draws a block for the TreeMapLayout with rounded corners instead of 90 degree angle corners.</p>
<pre class="actionscript">&nbsp;
&nbsp;
package com.<span class="me1">extralongfingers</span>.<span class="me1">graphs</span>.<span class="me1">client</span>.<span class="me1">render</span>
<span class="br0">&#123;</span>
	<span class="kw3">import</span> flare.<span class="me1">vis</span>.<span class="kw3">data</span>.<span class="me1">DataSprite</span>;
	<span class="kw3">import</span> flare.<span class="me1">vis</span>.<span class="kw3">data</span>.<span class="me1">render</span>.<span class="me1">IRenderer</span>;
&nbsp;
	<span class="kw3">import</span> flash.<span class="me1">display</span>.<span class="me1">GradientType</span>;
	<span class="kw3">import</span> flash.<span class="me1">display</span>.<span class="me1">Graphics</span>;
	<span class="kw3">import</span> flash.<span class="me1">geom</span>.<span class="me1">Matrix</span>;
&nbsp;
	<span class="kw3">public</span> <span class="kw2">class</span> RoundBlockRenderer <span class="kw3">implements</span> IRenderer
	<span class="br0">&#123;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw3">static</span> const ROUNDED_BLOCK : <span class="kw3">String</span> = <span class="st0">&quot;roundedblock&quot;</span>;
&nbsp;
		<span class="kw3">private</span> <span class="kw3">static</span> <span class="kw2">var</span> _instance:RoundBlockRenderer = <span class="kw2">new</span> RoundBlockRenderer<span class="br0">&#40;</span><span class="br0">&#41;</span>;
&nbsp;
		<span class="kw3">public</span> <span class="kw2">var</span> _defaultSize:<span class="kw3">Number</span>;
&nbsp;
		<span class="kw3">public</span> <span class="kw3">static</span> <span class="kw2">function</span> <span class="kw3">get</span> instance<span class="br0">&#40;</span><span class="br0">&#41;</span>:RoundBlockRenderer <span class="br0">&#123;</span> <span class="kw1">return</span> _instance; <span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw2">function</span> RoundBlockRenderer<span class="br0">&#40;</span>defaultSize : <span class="kw3">Number</span> = <span class="nu0">6</span><span class="br0">&#41;</span>
		<span class="br0">&#123;</span>
			<span class="kw3">this</span>._defaultSize = defaultSize;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw2">function</span> render<span class="br0">&#40;</span>d:DataSprite<span class="br0">&#41;</span>:<span class="kw3">void</span>
		<span class="br0">&#123;</span>
			<span class="kw2">var</span> <span class="kw3">size</span>:<span class="kw3">Number</span> = d.<span class="kw3">size</span> * _defaultSize;
			<span class="kw2">var</span> g : Graphics = d.<span class="me1">graphics</span>;
			g.<span class="kw3">clear</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
			<span class="kw2">var</span> _n : <span class="kw3">Number</span> = <span class="kw3">Math</span>.<span class="kw3">random</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
			g.<span class="kw3">beginGradientFill</span><span class="br0">&#40;</span> 	GradientType.<span class="me1">LINEAR</span>,
									<span class="br0">&#91;</span> 0xffffffff* _n,0xaaaaaaaa* _n, 0x8c8c8cff* _n, 0x000000 <span class="br0">&#93;</span>,
									<span class="br0">&#91;</span> .<span class="nu0">8</span>, .<span class="nu0">8</span>, .<span class="nu0">8</span>, .<span class="nu0">8</span> <span class="br0">&#93;</span>,
									<span class="br0">&#91;</span> <span class="nu0">0</span>,<span class="nu0">96</span>, <span class="nu0">128</span>, <span class="nu0">180</span> <span class="br0">&#93;</span>,
									<span class="kw2">new</span> Matrix<span class="br0">&#40;</span><span class="br0">&#41;</span>
								<span class="br0">&#41;</span>;
&nbsp;
			<span class="kw1">switch</span><span class="br0">&#40;</span> d.<span class="me1">shape</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp;
				<span class="kw1">case</span> ROUNDED_BLOCK:
					g.<span class="me1">drawRoundRect</span><span class="br0">&#40;</span>d.<span class="me1">u</span>-d.<span class="me1">x</span>, d.<span class="me1">v</span>-d.<span class="me1">y</span>, d.<span class="me1">w</span>, d.<span class="me1">h</span>, <span class="nu0">8</span>, <span class="nu0">8</span><span class="br0">&#41;</span>;
				<span class="kw1">break</span>;
			<span class="br0">&#125;</span>
&nbsp;
		<span class="br0">&#125;</span>
&nbsp;
	<span class="br0">&#125;</span>
<span class="br0">&#125;</span>
&nbsp;</pre>
<p>Source Code ::<a href="http://extralongfingers.com/wordpress/wp-content/uploads/2008/10/flare_rounded_block_renderer.zip" title="Rounded Block Renderer Source.">Rounded Block Renderer Source.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://extralongfingers.com/wordpress/?feed=rss2&amp;p=25</wfw:commentRss>
		</item>
		<item>
		<title>Visualizing PureMVC with Flare</title>
		<link>http://extralongfingers.com/wordpress/?p=24</link>
		<comments>http://extralongfingers.com/wordpress/?p=24#comments</comments>
		<pubDate>Sun, 31 Aug 2008 22:57:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://extralongfingers.com/wordpress/?p=24</guid>
		<description><![CDATA[And yet another visualization of an actionscript code framework :: PureMVC :: 
 
]]></description>
			<content:encoded><![CDATA[<p>And yet another visualization of an actionscript code framework :: PureMVC :: 
<p style="text-align: center"> <a href="http://extralongfingers.com/visualization/code/puremvc/puremvc.html" title="Radial Graph of PureMVC"><img src="http://extralongfingers.com/visualization/code/puremvc/puremvcVis.png" alt="Radial Graph PureMVC" width="376" height="341" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://extralongfingers.com/wordpress/?feed=rss2&amp;p=24</wfw:commentRss>
		</item>
		<item>
		<title>Visualizing Cairngorm with Flare</title>
		<link>http://extralongfingers.com/wordpress/?p=23</link>
		<comments>http://extralongfingers.com/wordpress/?p=23#comments</comments>
		<pubDate>Sun, 31 Aug 2008 22:46:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[visualization]]></category>

		<category><![CDATA[cairngorm]]></category>

		<category><![CDATA[flare]]></category>

		<category><![CDATA[graph]]></category>

		<guid isPermaLink="false">http://extralongfingers.com/wordpress/?p=23</guid>
		<description><![CDATA[Here's another visualization of an actionscript framework. This time its the very simple Adobe Cairngorm framework.  I also tried out using the Transitioner Class from the Flare framework to straighten the edges of the graph when the visualization loads.  
 
]]></description>
			<content:encoded><![CDATA[<p>Here's another visualization of an actionscript framework. This time its the very simple Adobe Cairngorm framework.  I also tried out using the Transitioner Class from the Flare framework to straighten the edges of the graph when the visualization loads.  
<p style="text-align: center"> <a href="http://www.extralongfingers.com/visualization/code/cairngorm/cairngorm.html" title="Cairngorm Radial Graph Visualization"><img src="http://www.extralongfingers.com/visualization/code/cairngorm/cairngormVis.png" alt="Cairngorm Visualization" width="392" height="413" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://extralongfingers.com/wordpress/?feed=rss2&amp;p=23</wfw:commentRss>
		</item>
		<item>
		<title>Visualizing Pixlib with Flare</title>
		<link>http://extralongfingers.com/wordpress/?p=22</link>
		<comments>http://extralongfingers.com/wordpress/?p=22#comments</comments>
		<pubDate>Sun, 31 Aug 2008 19:14:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[visualization]]></category>

		<category><![CDATA[graph]]></category>

		<category><![CDATA[graph theory]]></category>

		<category><![CDATA[pixlib]]></category>

		<guid isPermaLink="false">http://extralongfingers.com/wordpress/?p=22</guid>
		<description><![CDATA[Here is another visualization much like the Papervision 3d visualization in the previous post.  I'm going to keep posting these code visualizations for actionscript libraries in the coming days as I get more time. 
 
]]></description>
			<content:encoded><![CDATA[<p>Here is another visualization much like the Papervision 3d visualization in the previous post.  I'm going to keep posting these code visualizations for actionscript libraries in the coming days as I get more time. 
<p style="text-align: center"> <a href="http://www.extralongfingers.com/visualization/code/pixlib/pixlib.html" title="Pixlib Flare Visualization"><img src="http://www.extralongfingers.com/visualization/code/pixlib/pixlibVis.png" align="middle" height="471" width="480" alt="Flare Visualization of Pixlib" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://extralongfingers.com/wordpress/?feed=rss2&amp;p=22</wfw:commentRss>
		</item>
		<item>
		<title>Visualizing Papervision 3d with Flare</title>
		<link>http://extralongfingers.com/wordpress/?p=21</link>
		<comments>http://extralongfingers.com/wordpress/?p=21#comments</comments>
		<pubDate>Sun, 31 Aug 2008 16:17:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Papervision]]></category>

		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://extralongfingers.com/wordpress/?p=21</guid>
		<description><![CDATA[So I've become quite interested in the Flare actionscript library for graphing and started playing around with it this weekend.  Using the example given here ::: Flare Dependency Graph , I wrote some perl that parses an actionscript source tree and creates a JSON file suitable for import into the Flare libraries.  So here is what Papervision [...]]]></description>
			<content:encoded><![CDATA[<p>So I've become quite interested in the Flare actionscript library for graphing and started playing around with it this weekend.  Using the example given here ::: <a href="http://flare.prefuse.org/apps/dependency_graph" title="Flare Code Dependency Graph">Flare Dependency Graph</a> , I wrote some perl that parses an actionscript source tree and creates a JSON file suitable for import into the Flare libraries.  So here is what Papervision looks like when graphed using Flare ::: 
<p style="text-align: center"><a href="http://extralongfingers.com/visualization/code/pv3d/pv3d.html" title="Papervision 3d Flare Visualization"><img src="http://www.extralongfingers.com/visualization/code/pv3d/pv3dVis.png" align="absmiddle" height="432" width="480" alt="Visualization of Papervision 3d " /> </a></p>
<p style="text-align: center"> </p>
<p style="text-align: left"> </p>
]]></content:encoded>
			<wfw:commentRss>http://extralongfingers.com/wordpress/?feed=rss2&amp;p=21</wfw:commentRss>
		</item>
		<item>
		<title>Recursive String Reverse Algorithm in Actionscript</title>
		<link>http://extralongfingers.com/wordpress/?p=20</link>
		<comments>http://extralongfingers.com/wordpress/?p=20#comments</comments>
		<pubDate>Sat, 19 Jul 2008 02:26:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[algorithms]]></category>

		<guid isPermaLink="false">http://extralongfingers.com/wordpress/?p=20</guid>
		<description><![CDATA[I've been playing around with recursive functions in actionscript for a bit now and yesterday came across this pretty cool one for reversing a string.  The code follows :  
&#160;
function Reverse&#40;s : String &#41; :  String &#123;
	var tmp : String = null;
&#160;
   if &#40; s.length == 1 &#41;  return s;
   [...]]]></description>
			<content:encoded><![CDATA[<p>I've been playing around with recursive functions in actionscript for a bit now and yesterday came across this pretty cool one for reversing a string.  The code follows :  </p>
<pre class="actionscript">&nbsp;
<span class="kw2">function</span> <span class="kw3">Reverse</span><span class="br0">&#40;</span>s : <span class="kw3">String</span> <span class="br0">&#41;</span> :  <span class="kw3">String</span> <span class="br0">&#123;</span>
	<span class="kw2">var</span> tmp : <span class="kw3">String</span> = <span class="kw2">null</span>;
&nbsp;
   <span class="kw1">if</span> <span class="br0">&#40;</span> s.<span class="kw3">length</span> == <span class="nu0">1</span> <span class="br0">&#41;</span>  <span class="kw1">return</span> s;
   <span class="kw1">else</span>
   <span class="br0">&#123;</span>
	   <span class="kw2">var</span> sLast 		: <span class="kw3">String</span> = s.<span class="kw3">substr</span><span class="br0">&#40;</span> s.<span class="kw3">length</span> <span class="nu0">-1</span>, s.<span class="kw3">length</span> <span class="br0">&#41;</span>;
	   <span class="kw2">var</span> sRemainder 	: <span class="kw3">String</span> = s.<span class="kw3">substr</span><span class="br0">&#40;</span> <span class="nu0">0</span>, s.<span class="kw3">length</span> <span class="nu0">-1</span> <span class="br0">&#41;</span>;
	  tmp = sLast + <span class="kw3">Reverse</span><span class="br0">&#40;</span> sRemainder <span class="br0">&#41;</span>;
	  <span class="kw1">return</span> tmp;
   <span class="br0">&#125;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="kw2">var</span> str : <span class="kw3">String</span> = <span class="st0">&quot;abcdef&quot;</span>;
<span class="kw3">trace</span><span class="br0">&#40;</span> <span class="kw3">Reverse</span><span class="br0">&#40;</span> str <span class="br0">&#41;</span> <span class="br0">&#41;</span>;
&nbsp;</pre>
<p>This little diagram I drew out helped me understand what the execution stack looked like :  <img src="http://extralongfingers.com/images/reversestring/reverse_algorithma.jpg" alt="Reverse String Algorithm Execution Stack" /> </p>
]]></content:encoded>
			<wfw:commentRss>http://extralongfingers.com/wordpress/?feed=rss2&amp;p=20</wfw:commentRss>
		</item>
		<item>
		<title>Automated Flex Project Generation</title>
		<link>http://extralongfingers.com/wordpress/?p=18</link>
		<comments>http://extralongfingers.com/wordpress/?p=18#comments</comments>
		<pubDate>Tue, 17 Jun 2008 20:27:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Flex]]></category>

		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[code generation]]></category>

		<category><![CDATA[flex actionscript autogeneration]]></category>

		<guid isPermaLink="false">http://extralongfingers.com/wordpress/?p=18</guid>
		<description><![CDATA[After reading the book Code Generation in Action I found I was in need of an simple and easy way to roll out Flex project foundations.  I create a script that works with a set of template files to build the standard project directory structure, a set of specified views, and a set of basic commands that [...]]]></description>
			<content:encoded><![CDATA[<p>After reading the book <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=http%3A%2F%2Fwww.amazon.com%2FCode-Generation-Action-Jack-Herrington%2Fdp%2F1930110979%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1215560509%26sr%3D8-1&amp;tag=extralongfing-20&amp;linkCode=ur2&amp;camp=1789&amp;creative=9325">Code Generation in Action</a><img src="http://www.assoc-amazon.com/e/ir?t=extralongfing-20&amp;l=ur2&amp;o=1" width="1" height="1" border="0" style="border-width: initial !important; border-color: initial !important; border-style: none !important; margin: 0px !important" /> I found I was in need of an simple and easy way to roll out Flex project foundations.  I create a script that works with a set of template files to build the standard project directory structure, a set of specified views, and a set of basic commands that add the views to a canvas and init the application.  The following shows the command line invocation of the perl that creates a Flex project with 5 separate views :<br><br># ./generate.pl  usage : generate.pl domain applicationName view1 view2 .. view98 view99<br><br># ./generate.pl extralongfingers mynewapplication helpbutton startbutton stopbutton extralongfingersbutton holymountbutton <br><br>After that runs we have a set of directories that looks like this :<br><br> <img src="http://www.extralongfingers.com/images/flexgeneration/flex_generation_directory_structure.png" height="650" width="425" alt="Flex Generation Directory Structure" />   Each view specified on the command line created a mxml file in the root directory of the namespace and a corresponding controller in the com.extralongfingers.mynewapplication.client.controllers directory.  If you run the script you will see that each mxml view registers itself with the controller that shares its name.  The script also creates an application mxml file call Mynewapplication.mxml in the root of the directory structure. This mxml application serves as the entry point for the app and proceeds to run the BuildViews Command upon initialization wherein all the mxml views are instantiated and proceed to link up with their controllers.  I'm planning to clean up this perl a bit in order to modularize things a bit more and hope to submit to cpan soon.  Let me know what you think and if you found this useful.  I've been doing a lot with code generation lately so come back soon for my AMF PHP remoting gateway generator.        <a href="http://www.extralongfingers.com/images/flexgeneration/codeGeneration.zip"> Flex Generation Framework Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://extralongfingers.com/wordpress/?feed=rss2&amp;p=18</wfw:commentRss>
		</item>
		<item>
		<title>ViewHelper in Actionscript 3.0</title>
		<link>http://extralongfingers.com/wordpress/?p=17</link>
		<comments>http://extralongfingers.com/wordpress/?p=17#comments</comments>
		<pubDate>Tue, 29 Apr 2008 00:16:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[actionscript]]></category>

		<category><![CDATA[design patterns]]></category>

		<guid isPermaLink="false">http://extralongfingers.com/wordpress/?p=17</guid>
		<description><![CDATA[I always found the MovieClipHelper.as of the Pixlib framework useful for rolling out applications in a quick and straightforward manner.  Although the newest iteration of the framework  LowRA is a useful and powerful xml driven environment to roll out RIAs, I still find the need for a manager to hold references to all my views.  The power of a centralized [...]]]></description>
			<content:encoded><![CDATA[<p>I always found the <a href="http://svn1.cvsdude.com/osflash/pixlib/trunk/framework/src/com/bourre/visual/MovieClipHelper.as" title="MovieClipHelper" target="_blank">MovieClipHelper.as</a> of the <a href="http://osflash.org/projects/pixlib" title="PixLib" target="_blank">Pixlib</a> framework useful for rolling out applications in a quick and straightforward manner.  Although the newest iteration of the framework <a href="http://osflash.org/projects/pixlib" title="LowRA" target="_blank"> LowRA</a> is a useful and powerful xml driven environment to roll out RIAs, I still find the need for a manager to hold references to all my views.  The power of a centralized repository of all views and standard methods for x, y manipulation is great to have around for any project.  I've also been looking through the Vegas framework and was unable to find a View Management tool along the same lines.  So I decided to roll my own using Pixlib as a basis and Vegas as my environment.   This little class does most of the things you'll find in the Pixlib version like holding all view references in a hash map.  This design principle makes managing views incredibly easy.  By just defining a single enum file of static strings, you can uniquely name all the views of your application and then subsequently access those views from anywhere in the application.  I find this useful when managing sizing and positioning of multiple views that are dependent upon one another.  So herein follows a quick and dirty ViewManager designed for Sprites in AS3. </p>
<pre class="actionscript">&nbsp;
package com.<span class="me1">extralongfingers</span>.<span class="me1">definitionalliterature</span>.<span class="me1">client</span>.<span class="me1">util</span>
<span class="br0">&#123;</span>
	<span class="kw3">import</span> flash.<span class="me1">display</span>.<span class="me1">DisplayObject</span>;
&nbsp;
	<span class="kw3">import</span> vegas.<span class="kw3">data</span>.<span class="me1">map</span>.<span class="me1">HashMap</span>;
&nbsp;
	<span class="kw3">import</span> flash.<span class="me1">geom</span>.<span class="me1">Point</span>;
	<span class="kw3">import</span> flash.<span class="me1">events</span>.<span class="me1">EventDispatcher</span>;
	<span class="kw3">import</span> flash.<span class="me1">display</span>.<span class="me1">Sprite</span>;
&nbsp;
	<span class="coMULTI">/**
	 * @author Gregory Sogorka
	 */</span>
	<span class="kw3">public</span> <span class="kw2">class</span> ViewHelper
	<span class="br0">&#123;</span>
		<span class="kw3">public</span> <span class="kw2">var</span> view 			: Sprite;
		<span class="kw3">public</span> <span class="kw2">var</span> _dispatcher  	: EventDispatcher = <span class="kw2">new</span> EventDispatcher<span class="br0">&#40;</span><span class="br0">&#41;</span>;
		<span class="kw3">private</span> <span class="kw3">static</span> <span class="kw2">var</span> _a 		: HashMap = <span class="kw2">new</span> HashMap<span class="br0">&#40;</span><span class="br0">&#41;</span>;
		<span class="kw3">private</span> <span class="kw2">var</span> _sName			: <span class="kw3">String</span>;
&nbsp;
		<span class="kw2">function</span> ViewHelper<span class="br0">&#40;</span> s : <span class="kw3">String</span>, spr : Sprite <span class="br0">&#41;</span>
		<span class="br0">&#123;</span>
			<span class="kw1">if</span><span class="br0">&#40;</span> spr == <span class="kw2">null</span> <span class="br0">&#41;</span> <span class="kw3">trace</span><span class="br0">&#40;</span> <span class="st0">&quot; You must pass a Sprite to the constructor.&quot;</span><span class="br0">&#41;</span>;
&nbsp;
			<span class="kw1">else</span>
			<span class="br0">&#123;</span>
				view = spr;
				_setName<span class="br0">&#40;</span> s <span class="br0">&#41;</span>;
			<span class="br0">&#125;</span>
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw2">function</span> setVisible<span class="br0">&#40;</span> b : <span class="kw3">Boolean</span> <span class="br0">&#41;</span> : <span class="kw3">void</span>
		<span class="br0">&#123;</span>
			<span class="kw1">if</span> <span class="br0">&#40;</span> b <span class="br0">&#41;</span>
			<span class="br0">&#123;</span>
				<span class="kw3">show</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
			<span class="br0">&#125;</span>
			<span class="kw1">else</span>
			<span class="br0">&#123;</span>
				<span class="kw3">hide</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;
			<span class="br0">&#125;</span>
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw2">function</span> <span class="kw3">hide</span><span class="br0">&#40;</span><span class="br0">&#41;</span> : <span class="kw3">void</span>
		<span class="br0">&#123;</span>
			view.<span class="kw3">visible</span> = <span class="kw2">false</span>;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw2">function</span> <span class="kw3">show</span><span class="br0">&#40;</span><span class="br0">&#41;</span> : <span class="kw3">void</span>
		<span class="br0">&#123;</span>
			view.<span class="kw3">visible</span> = <span class="kw2">true</span>;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw2">function</span> move<span class="br0">&#40;</span> x : <span class="kw3">Number</span>, y : <span class="kw3">Number</span> <span class="br0">&#41;</span> : <span class="kw3">void</span>
		<span class="br0">&#123;</span>
			view.<span class="me1">x</span> = x;
			view.<span class="me1">y</span> = y;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw2">function</span> getPosition<span class="br0">&#40;</span><span class="br0">&#41;</span> : Point
		<span class="br0">&#123;</span>
			<span class="kw1">return</span> <span class="kw2">new</span> Point<span class="br0">&#40;</span> view.<span class="me1">x</span>, view.<span class="me1">y</span> <span class="br0">&#41;</span>;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw2">function</span> setSize<span class="br0">&#40;</span> w : <span class="kw3">Number</span>, h : <span class="kw3">Number</span> <span class="br0">&#41;</span> : <span class="kw3">void</span>
		<span class="br0">&#123;</span>
			view.<span class="kw3">width</span> = w;
			view.<span class="kw3">height</span> = h;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw2">function</span> <span class="kw3">getSize</span><span class="br0">&#40;</span><span class="br0">&#41;</span> : Point
		<span class="br0">&#123;</span>
			<span class="kw1">return</span> <span class="kw2">new</span> Point<span class="br0">&#40;</span> view.<span class="kw3">width</span>, view.<span class="kw3">height</span> <span class="br0">&#41;</span>;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw2">function</span> getName<span class="br0">&#40;</span><span class="br0">&#41;</span> : <span class="kw3">String</span>
		<span class="br0">&#123;</span>
			<span class="kw1">return</span> _sName;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw2">function</span> release<span class="br0">&#40;</span><span class="br0">&#41;</span> : <span class="kw3">void</span>
		<span class="br0">&#123;</span>
			ViewHelper._unregister<span class="br0">&#40;</span> _sName <span class="br0">&#41;</span>;
			_sName = <span class="kw2">null</span>;
		<span class="br0">&#125;</span>	
&nbsp;
		<span class="kw3">public</span> <span class="kw2">function</span> isVisible<span class="br0">&#40;</span><span class="br0">&#41;</span> : <span class="kw3">Boolean</span>
		<span class="br0">&#123;</span>
			<span class="kw1">return</span> view.<span class="kw3">visible</span>;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw3">static</span> <span class="kw2">function</span> getMovieClipHelper<span class="br0">&#40;</span> sName:<span class="kw3">String</span> <span class="br0">&#41;</span> : ViewHelper
		<span class="br0">&#123;</span>
			<span class="kw1">if</span> <span class="br0">&#40;</span>!ViewHelper._a.<span class="me1">containsKey</span><span class="br0">&#40;</span> sName <span class="br0">&#41;</span> <span class="br0">&#41;</span>
			<span class="br0">&#123;</span>
				<span class="kw3">trace</span><span class="br0">&#40;</span> <span class="st0">&quot;Can't find ViewHelper instance with '&quot;</span> + sName + <span class="st0">&quot;' name.&quot;</span> <span class="br0">&#41;</span>;
			<span class="br0">&#125;</span>
			<span class="kw1">return</span> _a.<span class="kw3">get</span><span class="br0">&#40;</span> sName <span class="br0">&#41;</span>;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">public</span> <span class="kw3">static</span> <span class="kw2">function</span> isRegistered<span class="br0">&#40;</span> sName:<span class="kw3">String</span> <span class="br0">&#41;</span> : <span class="kw3">Boolean</span>
		<span class="br0">&#123;</span>
			<span class="kw1">return</span> ViewHelper._a.<span class="me1">containsKey</span><span class="br0">&#40;</span> sName <span class="br0">&#41;</span>;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="co1">//Private methods.</span>
&nbsp;
		<span class="kw3">private</span> <span class="kw2">function</span> _setName<span class="br0">&#40;</span> <span class="kw3">name</span>:<span class="kw3">String</span> <span class="br0">&#41;</span> : <span class="kw3">void</span>
		<span class="br0">&#123;</span>
			<span class="kw1">if</span> <span class="br0">&#40;</span> ViewHelper._register<span class="br0">&#40;</span> <span class="kw3">name</span>, <span class="kw3">this</span> <span class="br0">&#41;</span> <span class="br0">&#41;</span> _sName = <span class="kw3">name</span>;
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">private</span> <span class="kw3">static</span> <span class="kw2">function</span> _register<span class="br0">&#40;</span> sName:<span class="kw3">String</span>, oHelper:ViewHelper <span class="br0">&#41;</span> : <span class="kw3">Boolean</span>
		<span class="br0">&#123;</span>
			<span class="kw1">if</span> <span class="br0">&#40;</span> ViewHelper._a.<span class="me1">containsKey</span><span class="br0">&#40;</span> sName <span class="br0">&#41;</span> <span class="br0">&#41;</span>
			<span class="br0">&#123;</span>
				<span class="kw3">trace</span><span class="br0">&#40;</span> <span class="st0">&quot;ViewHelper instance is already registered with '&quot;</span> + sName + <span class="st0">&quot;' name.&quot;</span> <span class="br0">&#41;</span>;
				<span class="kw1">return</span> <span class="kw2">false</span>;
			<span class="br0">&#125;</span>
			<span class="kw1">else</span>
			<span class="br0">&#123;</span>
				ViewHelper._a.<span class="me1">put</span><span class="br0">&#40;</span> sName, oHelper <span class="br0">&#41;</span>;
				<span class="kw1">return</span> <span class="kw2">true</span>;
			<span class="br0">&#125;</span>
		<span class="br0">&#125;</span>
&nbsp;
		<span class="kw3">private</span> <span class="kw3">static</span> <span class="kw2">function</span> _unregister<span class="br0">&#40;</span> sName:<span class="kw3">String</span> <span class="br0">&#41;</span> : <span class="kw3">void</span>
		<span class="br0">&#123;</span>
			ViewHelper._a.<span class="me1">remove</span><span class="br0">&#40;</span> sName <span class="br0">&#41;</span>;
		<span class="br0">&#125;</span>
&nbsp;
	<span class="br0">&#125;</span>
<span class="br0">&#125;</span>
&nbsp;</pre>
<p>    If you have any suggestions or improvements that might make this type of thing work even better drop me a line.</p>
]]></content:encoded>
			<wfw:commentRss>http://extralongfingers.com/wordpress/?feed=rss2&amp;p=17</wfw:commentRss>
		</item>
	</channel>
</rss>
