<?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>Robots w/Lasers &#187; Flash</title>
	<atom:link href="http://blog.davr.org/category/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.davr.org</link>
	<description>Nintendo DS &#038; GBA development, microcontrollers, and occasionally FPGAs</description>
	<lastBuildDate>Thu, 08 Jul 2010 17:22:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Simple Cellular Automata Example in AS3</title>
		<link>http://blog.davr.org/2008/08/22/simple-cellular-automata-example-in-as3/</link>
		<comments>http://blog.davr.org/2008/08/22/simple-cellular-automata-example-in-as3/#comments</comments>
		<pubDate>Fri, 22 Aug 2008 19:33:39 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[cellular automata]]></category>
		<category><![CDATA[chaos]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://blog.davr.org/?p=80</guid>
		<description><![CDATA[To get a little more experience with ActionScript 3, I wrote up a very simple class which will take a rule number, and then generate a cellular automata based on that. Read the full post to see the result, as well as the code.]]></description>
			<content:encoded><![CDATA[<p>To get a little more experience with ActionScript 3, I wrote up a very simple class which will take a rule number, and then generate a cellular automata based on that. </p>
<p>The movie below requires Flash 9 or above to be installed. Some rules to try out: 90, 30, 73, 110, 150. Valid numbers are 0-255, but not all produce interesting results.<br />

<object width="601" height="300">
<param name="movie" value="http://blog.davr.org/wp-content/uploads/2008/08/cellularautomata.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="601" height="300" src="http://blog.davr.org/wp-content/uploads/2008/08/cellularautomata.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p><a href="http://blog.davr.org/wp-content/uploads/2008/08/cellularautomata.swf">Direct link to flash movie</a> (got some people complaining the SWFObject script doesn't work under Vista)</p>
<p>See <a href="http://en.wikipedia.org/wiki/Cellular_automata">Wikipedia</a> for more info, and <a href="http://mathworld.wolfram.com/ElementaryCellularAutomaton.html">Wolfram.com</a> has a list of all 256 possible results<br />
Here's the code:<br />
<span id="more-80"></span></p>
<div class="igBar"><span id="lactionscript-1"><a href="#" onclick="javascript:showPlainTxt('actionscript-1'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-1">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"> * Simple Cellular Automata example</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"> * by David Rorex, 2008</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"> */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.*;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.*;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">geom</span>.*;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.*;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">ui</span>.<span style="color: #006600;">Keyboard</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">utils</span>.<span style="color: #0066CC;">getTimer</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> sim.<span style="color: #006600;">EasyButton</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> Sprite</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/// Holds the data we draw onto</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> bdata:BitmapData;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/// Bitmap container for displaying our rendering</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> bitmap:Bitmap;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/// Text field for typing in rule numbers</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> inp:<span style="color: #0066CC;">TextField</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/// Button to click to render</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> btn:EasyButton;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/// Constructor</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span>&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// set up the input textfield</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addChild<span style="color: #66cc66;">&#40;</span>inp<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #0066CC;">type</span> = TextFieldType.<span style="color: #006600;">INPUT</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #0066CC;">border</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"90"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>KeyboardEvent.<span style="color: #006600;">KEY_UP</span>, onEnter<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;color:#800000;">20</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// set up the render button</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; btn = <span style="color: #000000; font-weight: bold;">new</span> EasyButton<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Render"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; btn.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:*<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span> doRender<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addChild<span style="color: #66cc66;">&#40;</span>btn<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// set the stage to not scale, and to get an event if the window changes size</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">scaleMode</span> = StageScaleMode.<span style="color: #006600;">NO_SCALE</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">stage</span>.<span style="color: #0066CC;">align</span> = StageAlign.<span style="color: #006600;">TOP_LEFT</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">RESIZE</span>, <span style="color: #0066CC;">onResize</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// initialize the size</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setSize<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>, <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * Event handler for when the stage changes size</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * @param e</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">onResize</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setSize<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>, <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * Event handler to catch the user pressing ENTER in the text field</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * @param e</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> onEnter<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:KeyboardEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">charCode</span> == Keyboard.<span style="color: #0066CC;">ENTER</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; doRender<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * Simple method to call the render function</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> doRender<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; render<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">parseInt</span><span style="color: #66cc66;">&#40;</span>inp.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * Adjust the positioning of our elements based on a given size</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * @param w</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * @param h</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setSize<span style="color: #66cc66;">&#40;</span>w:<span style="color: #0066CC;">Number</span>, h:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; btn.<span style="color: #006600;">x</span> = w - btn.<span style="color: #0066CC;">width</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #0066CC;">width</span> = w - btn.<span style="color: #0066CC;">width</span> - <span style="color: #cc66cc;color:#800000;">2</span>;&nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * Render cellular automata.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; * @param ruleNum - the number of the rule to draw. Some interesting numbers are '30' and '90'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> render<span style="color: #66cc66;">&#40;</span>ruleNum:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// clean up previous bitmap</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>bitmap != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; removeChild<span style="color: #66cc66;">&#40;</span>bitmap<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bitmap = <span style="color: #000000; font-weight: bold;">null</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>bdata != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata.<span style="color: #006600;">dispose</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata = <span style="color: #000000; font-weight: bold;">null</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// get width and height of the stage</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> w:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> h:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span> - <span style="color: #cc66cc;color:#800000;">20</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// build lookup table based on the rule number</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> rule:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">0</span>; i &lt;<span style="color: #cc66cc;color:#800000;">8</span>; i++<span style="color: #66cc66;">&#41;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rule<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> = <span style="color: #66cc66;">&#40;</span>ruleNum&gt;&gt; i<span style="color: #66cc66;">&#41;</span> &amp; <span style="color: #cc66cc;color:#800000;">1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// create bitmap data that we will draw into</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata = <span style="color: #000000; font-weight: bold;">new</span> BitmapData<span style="color: #66cc66;">&#40;</span>w, h, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// lock the bitmap data, provides speedups when you are doing a lot of manipulations</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata.<span style="color: #006600;">lock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// set the starting data - a single pixel in the center</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata.<span style="color: #006600;">setPixel</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span>w/<span style="color: #cc66cc;color:#800000;">2</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;color:#800000;">0</span>, <span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// loop row by row</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> y:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">1</span>; y &lt;h; y++<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// loop pixel by pixel</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> x:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">0</span>; x &lt;w; x++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// use lookup table based up 3 neighboring pixels to calculate new pixel</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata.<span style="color: #006600;">setPixel</span><span style="color: #66cc66;">&#40;</span>x, y,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rule<span style="color: #66cc66;">&#91;</span>bdata.<span style="color: #006600;">getPixel</span><span style="color: #66cc66;">&#40;</span>x - <span style="color: #cc66cc;color:#800000;">1</span>, y - <span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span> &lt;&lt;<span style="color: #cc66cc;color:#800000;">2</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; | bdata.<span style="color: #006600;">getPixel</span><span style="color: #66cc66;">&#40;</span>x&nbsp; &nbsp; , y - <span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span> &lt;&lt;<span style="color: #cc66cc;color:#800000;">1</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; | bdata.<span style="color: #006600;">getPixel</span><span style="color: #66cc66;">&#40;</span>x + <span style="color: #cc66cc;color:#800000;">1</span>, y - <span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// map the pixels, 0-white, 1-black</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata.<span style="color: #006600;">paletteMap</span><span style="color: #66cc66;">&#40;</span>bdata, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span>, <span style="color: #cc66cc;color:#800000;">0</span>, w, h<span style="color: #66cc66;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span>, <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span>, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #66cc66;">&#91;</span>0xffffff, <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bdata.<span style="color: #006600;">unlock</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// unlock the bitmap data</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// create the bitmap to hold the data</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bitmap = <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span>bdata, PixelSnapping.<span style="color: #006600;">ALWAYS</span>, <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bitmap.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;color:#800000;">21</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addChildAt<span style="color: #66cc66;">&#40;</span>bitmap,<span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// add it to our display list so we can see it</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2008/08/22/simple-cellular-automata-example-in-as3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Updates for Flex Builder 2 on Linux</title>
		<link>http://blog.davr.org/2007/05/07/updates-for-flex-builder-2-on-linux/</link>
		<comments>http://blog.davr.org/2007/05/07/updates-for-flex-builder-2-on-linux/#comments</comments>
		<pubDate>Mon, 07 May 2007 08:08:57 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2007/05/07/updates-for-flex-builder-2-on-linux/</guid>
		<description><![CDATA[If you are looking to run Flex Builder 2 on Linux, see my original post. I've made two minor updates for people using Flex Builder 2 on Linux. The first is to eliminate the annoying "Incorrect flash player installed...you have 0.0.0.0, and need 9.0.0.0" that pops up every time you run a project. To fix [...]]]></description>
			<content:encoded><![CDATA[<p>If you are looking to run Flex Builder 2 on Linux, <a href="http://blog.davr.org/linux-flex-builder-2/">see my original post</a>.</p>
<p>I've made two minor updates for people using Flex Builder 2 on Linux. The first is to eliminate the annoying "Incorrect flash player installed...you have 0.0.0.0, and need 9.0.0.0" that pops up every time you run a project. To fix it:</p>
<ol>
<li>Download <a href="http://davr.org/flash/debugui.jar">debugui.jar</a></li>
<li>Overwrite the file eclipse/plugins/com.adobe.flexbuilder.debug.ui_2.0.155577/debugui.jar with the downloaded one</li>
</ol>
<p>The second minor update: I've noticed some very annoying bugs in the linux flash player (all reported to Adobe now of course), but in the mean time, I've been using the windows flash player under WINE, which does not have the same bugs. If you want to do this (which will probably greatly reduce performance), all you really need is to:</p>
<ol>
<li>Make sure you have WINE installed correctly</li>
<li>Download the <a href="http://www.adobe.com/support/flashplayer/downloads.html#fp9">windows standalone projector debugger</a></li>
<li>Write a wrapper script that calls wine on the windows .exe, this wrapper will then be called by flex builder. You can <a href="http://davr.org/flash/flashplayer">see my sampe script</a> to start (it's very simple, just need to adjust for your paths/filenames).</li>
</ol>
<p>In other news, I'm working on my first AS3 application that is above the tech-demo level! Well...so far haven't gotten much, but I've got code that compiles on both Linux Flex Builder 2, as well as Windows FlashDevelop, with no changes (yay!). You can <a href="http://davr.org/flash/swf.php?swf=rider_as3&#038;w=600&#038;h=600">see what I have so far</a>, but not it's not very exciting yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2007/05/07/updates-for-flex-builder-2-on-linux/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Open Source Flash FUD</title>
		<link>http://blog.davr.org/2007/04/26/open-source-flash-fud/</link>
		<comments>http://blog.davr.org/2007/04/26/open-source-flash-fud/#comments</comments>
		<pubDate>Thu, 26 Apr 2007 15:32:46 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2007/04/26/open-source-flash-fud/</guid>
		<description><![CDATA[Every time someone mentions open sourcing the flash player, someone always jumps up to defend Adobe (formerly Macromedia...I'll always think of Flash as a MM product). There are many good reasons why they may not want to opensource the runtime, but the fear of having multiple incompatible runtimes is not one of them. The 'OMG [...]]]></description>
			<content:encoded><![CDATA[<p>Every time someone mentions open sourcing the flash player, someone always jumps up to defend Adobe (formerly Macromedia...I'll always think of Flash as a MM product). There are many good reasons why they may not want to opensource the runtime, but the fear of having multiple incompatible runtimes is not one of them.</p>
<p>The 'OMG incompatible versions' thing is just a bunch of FUD. If Adobe kept control of the player, there would not be any issue with this. Sure, you might have 1 or 2% of the users branching off to make their own versions, but they already do this anyway! (see gnash, also that other opensource flash player). If the official player were open sourced, then the branches would be much more compatible. Gnash lacks in a lot of areas, and only supports up to F7, imagine if they could reuse code from the official player. So you would actually gain more compatibility by opensourcing, not less!</p>
<p>Notes on <a href="http://www.blairsblog.com/2007/04/i_dont_understa.html">Blair's post</a>:</p>
<ol>
<li>Microsoft's JVM was not made by branching an open-source copy of Sun's JVM. It was made by microsoft, and they PURPOSEFULLY made it incompatible, to try and encorage platform lock-in. After the whole suit from Sun, a few years later they made their own language / platform (C# / .NET), and achieved the same goals. (Platform lockin. No, Mono is not a good substitute for 90% of apps)</li>
<li>Microsoft's JVM did not kill Java in the browser, Java sucking is what killed Java in the browser.</li>
<li>Sun's JVM just went GPL recently, and there hasn't been an explosion of dozens of incompatible JVMs. In fact, off the top of my head, I cannot think of a single JVM besides the official one, because that's what I always use, on windows, mac, and linux. Sure there are different versions, but the same applies to flash, and to any non-dead technology.</li>
</ol>
<p>(Personally I do not like the GPL, it has some real problems, but that's a topic for another day)</p>
<p>For the case of the flash player, imagine that we still had ExpressInstall, and that it always pointed at the official Adobe upgrade site. The only people who might even possibly install an incompatible version, are the fringe users, and they would be fully aware of what they are doing. The average user who just sees 'New version of flash, click OK' would always have the official version.</p>
<p>I wish people would stop resorting to this argument against flash being open source. Why not just use the real ones?</p>
<ol>
<li>Adobe makes lots of money selling flash player to device manufacturers.</li>
<li>Adobe uses expensive proprietary audio and video codes which they cannot open source.</li>
<li>Probably a few others as well, but the above two are the main ones in my mind.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2007/04/26/open-source-flash-fud/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flex Builder 2.01 under Linux</title>
		<link>http://blog.davr.org/2007/04/22/flex-builder-201-under-linux/</link>
		<comments>http://blog.davr.org/2007/04/22/flex-builder-201-under-linux/#comments</comments>
		<pubDate>Mon, 23 Apr 2007 07:14:45 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2007/04/22/flex-builder-201-under-linux/</guid>
		<description><![CDATA[UPDATE! Official Flex Builder 3 for Linux!! Check it out here! The stuff below is left here for posterity's sake...but you probably want the link above, and forget everything below... With a bit of tweaking, I've gotten Flex Builder 2.01 working under Linux. Everything seems to work, including debugging, except for the Design view. Here [...]]]></description>
			<content:encoded><![CDATA[<p><font color="red"><b>UPDATE! Official Flex Builder 3 for Linux!!</b></font><br />
<a href="http://labs.adobe.com/technologies/flex/flexbuilder_linux/">Check it out here!</a></p>
<p>The stuff below is left here for posterity's sake...but you probably want the link above, and forget everything below...</p>
<hr />
<p>With a bit of tweaking, I've gotten Flex Builder 2.01 working under Linux. Everything seems to work, including debugging, except for the Design view. </p>
<p>Here is a brief outline:</p>
<ol>
<li>Download and extract Eclipse. I used <a href="http://www.eclipse.org/downloads/">Eclipse SDK 3.2.2</a> <b>NOTE:</b> I could not get it to work when eclipse was installed in /usr. Unless you can figure it out, do not install eclipse via your OS, simply download the .tgz and extract it to your home directory.</li>
<li>Download and extract the free <a href="http://www.adobe.com/cfusion/tdrc/index.cfm?product=flex">Flex 2.01 SDK</a>.</li>
<li>Download and install the Flex Charting Components (same link as above) Run the installer by <code>java -jar flex_charting_2_installer.jar</code> and install it to the root of your Flex2 SDK directory.</li>
<li>Download the <a href="http://www.adobe.com/support/flashplayer/downloads.html#fp9">Flash 9 Debugging player</a>
<ol>
<li>install the plugin into your browser by running plugin/debugger/install_flash_player_9_linux/flashplayer-installer. </li>
<li>(as root) copy standalone/debugger/flashplayer to /usr/local/bin</li>
<li>create a symlink for gflashplayer, (as root) <code>ln -s /usr/local/bin/flashplayer /usr/local/bin/gflashplayer</code></li>
</ol>
<li>Download the <a href="http://davr.org/flash/FlexBuilder_2.01_for_Linux.tar.gz">FlexBuilder 2.01 Plugin for Linux</a> (<a href="http://labs.eshangrao.com/files/FlexBuilder_2.01_for_Linux.tar.gz">mirror</a>)
<ol>
<li>Extract this to the root eclipse install folder. It will create files in the configuration, plugins, and features directories which are already part of eclipse.</li>
<li>Open <code>eclipse/configuration/com.adobe.flexbuilder/flexbuilder2.xml</code> and change the value of &lt;sdkpath&gt; to point to the root directory where you installed the Flex 2 SDK</li>
</ol>
<li>(OPTIONAL) Fix the annoying 'Incorrect flash player installed' popup every time you run your project:
<ol>
<li>Download <a href="http://davr.org/flash/debugui.jar">debugui.jar</a></li>
<li>Overwrite the file eclipse/plugins/com.adobe.flexbuilder.debug.ui_2.0.155577/debugui.jar with the downloaded one</li>
</ol>
</li>
<li>(OPTIONAL) Use the windows flash player with WINE instead of native linux flash player.
<ol>
<li>Make sure you have WINE installed correctly</li>
<li>Download the windows standalone projector debugger (see link at top for player downloads)</li>
<li>Download <a href="http://davr.org/flash/flashplayer">this flashplayer script</a> and place in your path, as well as rename the linux player so it doesn't interfere. You probably still need the symlink to gflashplayer as above.</li>
</ol>
</li>
<li>(OPTIONAL) If you already use eclipse, it's possible it wont see the new Flex plugins. Simply run the following command to get eclipse to search for your newly installed stuff:
<ol>
<li>"./eclips -clean"</li>
</ol>
</ol>
<p>That should be it! The only problem I've had is switching to design view messes everything up. Just stay in source view and you'll be fine. Also, whenever I try to debug, it says I don't have flash 9 installed, but I just press continue, and debugging works like normal (catching traces, breakpoint on crash, etc).</p>
<p>Thanks to <a href="http://blog.eshangrao.com/index.php/2007/01/16/324-flexbuilder-201-for-linux%C2%A0">this chinese guy's post</a> for figuring it out. He has a few more posts on the issue (<a href="http://blog.eshangrao.com/index.php/2007/03/07/357-flexbuilder-201-for-linux-patch-11">[1]</a>, <a href="http://blog.eshangrao.com/index.php/2007/03/08/360-flexbuilder-201-for-linux-v12">[2]</a>),  but I didn't seem to need any of the info in them.</p>
<p>Somewhat related, <a href="http://osflash.org/pipermail/papervision3d_osflash.org/2007-February/001662.html">this post</a> talks about other ways of using Flex 2 / AS3 under linux.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2007/04/22/flex-builder-201-under-linux/feed/</wfw:commentRss>
		<slash:comments>85</slash:comments>
		</item>
		<item>
		<title>Apollo Intrinsic Classes</title>
		<link>http://blog.davr.org/2007/04/20/apollo-intrinsic-classes/</link>
		<comments>http://blog.davr.org/2007/04/20/apollo-intrinsic-classes/#comments</comments>
		<pubDate>Fri, 20 Apr 2007 16:01:19 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Apollo]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2007/04/20/apollo-intrinsic-classes/</guid>
		<description><![CDATA[UPDATE: Complete &#38; accurate versions can be found by brainy at flashdevelop forums, much better than my unfinished attempt. I have written a quick &#038; hacky script to parse the]]></description>
			<content:encoded><![CDATA[<p>UPDATE: Complete &amp; accurate versions can be found by <a href="http://www.flashdevelop.org/community/viewtopic.php?t=1400">brainy at flashdevelop forums</a>, much better than my unfinished attempt.</p>
<p>I have written a quick &#038; hacky script to parse the <a href="http://labs.adobe.com/wiki/index.php/Apollo:Documentation:API_Reference"apollo reference</a> to create intrinsic classes. It is not perfect, and they still need a bit of cleanup by hand (imports, a few syntax errors here and there). But I've gotten a good 90% of the hard work done.</p>
<p>These would be useful for anyone using a IDE besides Flex Builder, in order to get autocomplete etc.</p>
<p>Please, if you do clean them up, post a comment, and I will link it here, so everyone can use them.</p>
<p>Download: <a href="http://davr.org/flash/ApolloIntrinsic_draft.zip">ApolloIntrinsic_draft.zip</a></p>
<p><b>UPDATE: </b> I tried again, this time by parsing the bytecodes from the SWC. There's only one problem, no paramater names (but I do have paramamter types). The cool part about this way, is that it shows all the undocumented and private methods as well!</p>
<p><b>UPDATE AGAIN: </b> was missing some classes due to not parsing dynamic or final classes.</p>
<p>Download: <a href="http://davr.org/flash/ApolloIntrinsic_draft3.zip">ApolloIntrinsic_draft3.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2007/04/20/apollo-intrinsic-classes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apollo App: AS3 Tip of the Day</title>
		<link>http://blog.davr.org/2007/04/05/apollo-app-as3-tip-of-the-day/</link>
		<comments>http://blog.davr.org/2007/04/05/apollo-app-as3-tip-of-the-day/#comments</comments>
		<pubDate>Fri, 06 Apr 2007 05:27:52 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Apollo]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2007/04/03/apollo-app-as3-tip-of-the-day/</guid>
		<description><![CDATA[This is another fairly quick app I wrote, it pulls the posts from senocular's AS3 Tip of the Day thread, and then displays them in a little browser (minus all the other forum cruft). It also caches them to disk, so each tip needs to be loaded only once. (sorry for the lame interface) AS3Tips.air [...]]]></description>
			<content:encoded><![CDATA[<p>This is another fairly quick app I wrote, it pulls the posts from senocular's <a href="http://kirupa.com/forum/showthread.php?t=223798">AS3 Tip of the Day</a> thread, and then displays them in a little browser (minus all the other forum cruft). It also caches them to disk, so each tip needs to be loaded only once.</p>
<p><img src="http://davr.org/pics/as3tips.png" width="570" height="477" /></p>
<p>(sorry for the lame interface)</p>
<p><a href="http://davr.org/flash/AS3Tips.air">AS3Tips.air</a> -- install file, requires <a href="http://labs.adobe.com/downloads/apolloruntime.html">Apollo Alpha Runtime</a>.<br />
<a href="http://davr.org/flash/AS3Tips.mxml">AS3Tips.mxml</a> -- source code</p>
<p>Thanks to <a href="http://www.senocular.com/?id=1.388">senocular</a> for writing these amazingly helpful AS3 tips!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2007/04/05/apollo-app-as3-tip-of-the-day/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Native file browse dialog in Apollo</title>
		<link>http://blog.davr.org/2007/03/28/native-file-browse-dialog-in-apollo/</link>
		<comments>http://blog.davr.org/2007/03/28/native-file-browse-dialog-in-apollo/#comments</comments>
		<pubDate>Thu, 29 Mar 2007 04:26:14 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Apollo]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2007/03/28/native-file-browse-dialog-in-apollo/</guid>
		<description><![CDATA[I haven't seen any examples on how to use the native OS browse dialogs for opening &#038; saving files, so here's a quick example. Basically, the idea is to use the File (which extends FileReference) class, and pretend to upload or download files from the net, but not actually perform the action, and just grab [...]]]></description>
			<content:encoded><![CDATA[<p>I haven't seen any examples on how to use the native OS browse dialogs for opening &#038; saving files, so here's a quick example.</p>
<p>Basically, the idea is to use the File (which extends FileReference) class, and pretend to upload or download files from the net, but not actually perform the action, and just grab the file's path directly.</p>
<p>This app allows you to load a PNG or JPEG, apply a blur effect, then save it as a JPEG again. It requires the JPGEncoder from <a href="http://code.google.com/p/as3corelib/">the AS3 corelib</a></p>
<p><a href="http://davr.org/flash/BrowseExample.mxml">Download BrowseExample.mxml</a> (only works with Apollo, not in a browser etc)</p>
<p><a href="http://davr.org/flash/BrowseExample.air">Install BrowseExample.air</a><br />
<span id="more-56"></span></p>
<pre>
<code>
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:ApolloApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
	title="Browse Example"
	backgroundColor="0x222222"&gt;

	&lt;mx:Script&gt;
		&lt;![CDATA[
			import mx.events.IndexChangedEvent;
			import mx.events.DragEvent;
			import mx.containers.Canvas;
			import mx.effects.effectClasses.BlurInstance;
			import flash.filesystem.*;
			import com.adobe.images.*;

			// File object for saving / loading
			private var file:File;

			// callback when slider is changed
			public function blurImg():void {
				// get the value from the slider
				var blurVal:Number = slider.value;

				// use the slider value to construct a blurring filter
				var filter:BlurFilter = new BlurFilter(blurVal, blurVal, 3);

				// apply the blur filter to the image
				img.filters = [filter];
			}

			public function saveImg():void {
				// start at desktop directory
				file = File.desktopDirectory; 

				// listen for when the user has selected a location to save
				file.addEventListener(Event.SELECT, onFileSave);

				// request a download a bogus file, to get the Browse dialog to pop up
				file.download(new URLRequest("http://foo/foo"), "blurred.jpg");
			}

			public function onFileSave(e:Event):void {

				// cancel the file download, since it was bogus anyway
				// now, 'file' now points at where they want to save
				file.cancel();

				// grab the pixel data from the image
				var bmpData:BitmapData = new BitmapData(img.width, img.height);
				bmpData.draw(img);

				// encode the pixel data into a JPEG
				var jpgEncoder:JPGEncoder = new JPGEncoder();
				var jpgBytes:ByteArray = jpgEncoder.encode(bmpData);

				// open a filestream from the file
				var stream:FileStream = new FileStream();
				stream.open(file, FileMode.WRITE);

				// write the jpeg data to the file
				stream.writeBytes(jpgBytes, 0, jpgBytes.length);

				// close the stream. the file is now saved.
				stream.close();				

			}

			public function loadImg():void {

				// start at the desktop directory
				file = File.desktopDirectory; 

				// listen for select event
				file.addEventListener(Event.SELECT, onFileLoad); 

				// open browse dialog to pick an image file
				file.browse([new FileFilter("Images", "*.jpg;*.png")]);
			}

			// handler for when user selects a file
			private function onFileLoad(e:Event):void {

				// 'file' now contains a url pointing at the file they selected.
				// in a flash movie, you would not have access to the full path,
				// but in apollo you do.
				trace(file.url);

				// load the image that they picked.
				// In Apollo, you can load from file://... URLs
				img.load(file.url);
			}

		]]&gt;
	&lt;/mx:Script&gt;
	&lt;mx:VBox left="5" top="5" bottom="5" right="5" horizontalAlign="center"&gt;
		&lt;mx:HBox width="100%"  horizontalAlign="center"&gt;
			&lt;mx:Button label="Load..." click="loadImg()"  /&gt;
			&lt;mx:Button label="Save as JPG..." click="saveImg()"  /&gt;
		&lt;/mx:HBox&gt;
		&lt;mx:HSlider id="slider" change="blurImg()"  minimum="1" maximum="25" snapInterval="0.2" width="90%"/&gt;
		&lt;mx:Image id="img" /&gt;
	&lt;/mx:VBox&gt;

&lt;/mx:ApolloApplication&gt;
</code>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2007/03/28/native-file-browse-dialog-in-apollo/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Lyric Station &#8211; Apollo App</title>
		<link>http://blog.davr.org/2007/03/21/lyric-station-apollo-app/</link>
		<comments>http://blog.davr.org/2007/03/21/lyric-station-apollo-app/#comments</comments>
		<pubDate>Thu, 22 Mar 2007 05:09:12 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Apollo]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2007/03/21/lyric-station-apollo-app/</guid>
		<description><![CDATA[I saw this post by Marcos P. who created an app for searching for song lyrics. I took it and added a few small enhancements: Download raw lyrics instead of html -- saves bandwidth &#038; time Better layout -- I take advantage of Flex's layout capabilities to make the interface resizable Partial match searching -- [...]]]></description>
			<content:encoded><![CDATA[<p>I saw <a href="http://www.placona.co.uk/blog/index.cfm/2007/3/21/Yet-another-first-Apollo-app--Lyric-Finder">this post by Marcos P.</a> who created an app for searching for song lyrics. I took it and added a few small enhancements:</p>
<ul>
<li>Download raw lyrics instead of html -- saves bandwidth &#038; time</li>
<li>Better layout -- I take advantage of Flex's layout capabilities to make the interface resizable</li>
<li>Partial match searching -- If a song is not found, I call out to the search page in the lyrics wiki, and then parse the results. This allows to find songs if you don't know the exact name, or miss a 'the', or to browse all songs by a certain artist</li>
</ul>
<p><img src="http://davr.org/pics/lyrics.png" width="508" height="402" /></p>
<p><a href="http://davr.org/flash/LyricStation.air">LyricStation.air</a> -- requires the <a href="http://labs.adobe.com/downloads/apolloruntime.html">Apollo Runtime Alpha 1</a> in order to use. AIR file also includes the source code.</p>
<p>Many thanks to Marcos for giving out the source! It's a great learning experience to hack on other people's code that they've already gotten started for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2007/03/21/lyric-station-apollo-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionscript3 Quickstart Reference</title>
		<link>http://blog.davr.org/2007/02/21/actionscript3-quickstart-reference/</link>
		<comments>http://blog.davr.org/2007/02/21/actionscript3-quickstart-reference/#comments</comments>
		<pubDate>Wed, 21 Feb 2007 22:52:59 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2007/02/21/actionscript3-quickstart-reference/</guid>
		<description><![CDATA[I put together a quick reference to getting started on writing Actionscript3 applications (which target the Flash 9 runtime), using only free tools (on Windows). Also a few handy documentation / language reference links. It's everything you need to start writing your own high-performance Flash applications, including PaperVision3D. Check it out.]]></description>
			<content:encoded><![CDATA[<p>I put together a quick reference to getting started on writing Actionscript3 applications (which target the Flash 9 runtime), using only free tools (on Windows). Also a few handy documentation / language reference links. It's everything you need to start writing your own high-performance Flash applications, including PaperVision3D. <a href="http://blog.davr.org/actionscript3-quickstart/">Check it out.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2007/02/21/actionscript3-quickstart-reference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PaperVision3D</title>
		<link>http://blog.davr.org/2007/02/13/papervision3d/</link>
		<comments>http://blog.davr.org/2007/02/13/papervision3d/#comments</comments>
		<pubDate>Tue, 13 Feb 2007 23:58:01 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2007/02/13/papervision3d/</guid>
		<description><![CDATA[This looks pretty neat, it's an opensource 3D library written completely in actionscript3, for flash9+. It's the first serious 3d engine I've seen in flash, and while it is still at an early stage (somewhat closed beta, if you join the mailing list you can find info on how to get it), it looks like [...]]]></description>
			<content:encoded><![CDATA[<p>This looks pretty neat, it's an opensource 3D library written completely in actionscript3, for flash9+. It's the first serious 3d engine I've seen in flash, and while it is still at an early stage (somewhat closed beta, if you join the mailing list you can find info on how to get it), it looks like it will be amazing. The coding is clean, and there is already some documentation (often rare in opensource projects).</p>
<p>Here is a quick test with some Bouncing Cubes that I've made:<br />
<span id="more-49"></span><br />
(requires Flash 9 player to view)<br />

<object width="600" height="500">
<param name="movie" value="http://davr.org/flash/BouncingCubes.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="600" height="500" src="http://davr.org/flash/BouncingCubes.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
<br />
(click to randomize velocity) <a href="http://davr.org/flash/BouncingCubes.as">main source file</a></p>
<p><a href="http://papervision3d.org/">Official Site</a> (not much yet)<br />
<a href="http://blog.papervision3d.org/">Development Blog</a> (has a bunch of other cool demos)<br />
<a href="http://www.osflash.org/papervision3d">OSFlash Page</a> (more info, a bit outdated)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2007/02/13/papervision3d/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
