<?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>mostly a codeBlog &#187; ActionScript3</title>
	<atom:link href="http://www.rickigregersen.com/category/actionscript3/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rickigregersen.com</link>
	<description>whatever I am currently programming... and I truly digress</description>
	<lastBuildDate>Mon, 21 Jun 2010 15:40:35 +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>SporeTree</title>
		<link>http://www.rickigregersen.com/2009/08/11/sporetree/</link>
		<comments>http://www.rickigregersen.com/2009/08/11/sporetree/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 21:21:02 +0000</pubDate>
		<dc:creator>Ricki</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[fun]]></category>
		<category><![CDATA[recursive]]></category>
		<category><![CDATA[spore]]></category>
		<category><![CDATA[tree]]></category>

		<guid isPermaLink="false">http://www.rickigregersen.com/?p=193</guid>
		<description><![CDATA[This time the spores turned into a tree. It is by no means perfect, the branches does not move upwards with the stem as it should, were this a real orange colored scary spore tree. This was just some &#8220;while Im doing nothing, let&#8217;s put whatever in the &#8216;fun&#8217; category&#8221; but if anyone would like [...]]]></description>
			<content:encoded><![CDATA[<p>This time the <a href="http://www.rickigregersen.com/?paged=2">spores</a> turned into a tree. It is by no means perfect, the branches does not move upwards with the stem as it should, were this a real orange colored scary spore tree.</p>
<p>This was just some &#8220;while Im doing nothing, let&#8217;s put whatever in the &#8216;fun&#8217; category&#8221; <img src='http://www.rickigregersen.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  but if anyone would like the code, throw me a comment and I&#8217;ll send it off. I is uncommented and messy.</p>
<p><object width="512" height="750" data="http://www.rickigregersen.com/wp-content/uploads/BitmapSporeGrowingTree.swf" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="scale" value="exactfit" /><param name="salign" value="l" /><param name="wmode" value="transparent" /><param name="src" value="http://www.rickigregersen.com/wp-content/uploads/BitmapSporeGrowingTree.swf" /></object></h4>
]]></content:encoded>
			<wfw:commentRss>http://www.rickigregersen.com/2009/08/11/sporetree/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Growing Homegrown Tentacles</title>
		<link>http://www.rickigregersen.com/2009/08/08/growing-homegrown-tentacles/</link>
		<comments>http://www.rickigregersen.com/2009/08/08/growing-homegrown-tentacles/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 23:30:19 +0000</pubDate>
		<dc:creator>Ricki</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.rickigregersen.com/?p=183</guid>
		<description><![CDATA[Well, I just got time to look into how to get the tentacles growing, i.e. start out small and have all the joints gradually increase in size, instead of the joint getting smaller all the time. (think I just tried to explain the definition of growing by using the definition of growing??). Thanks again to [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I just got time to look into how to get the tentacles growing, i.e. start out small and have all the joints gradually increase in size, instead of the joint getting smaller all the time. (think I just tried to explain the definition of growing by using the definition of growing??).</p>
<p>Thanks again to <a href="http://blog.soulwire.co.uk/">Justin</a>.</p>
<p><object width="512" height="512" data="http://www.rickigregersen.com/wp-content/uploads/BitmapSporeGrowing.swf" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="scale" value="exactfit" /><param name="salign" value="l" /><param name="wmode" value="transparent" /><param name="src" value="http://www.rickigregersen.com/wp-content/uploads/BitmapSporeGrowing.swf" /></object></h4>
<p>The spore Class turned out to look like this, it needs going over, but I was thinking on porting it to Processing and really get my tentacles on <img src='http://www.rickigregersen.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The code:</p>
<pre lang="actionscript">
package
{
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.utils.setTimeout;

	public class Spore extends Sprite
	{
		private static const LENGTH:int = 90;
		private var _posX:Vector.<Number>;
		private var _posY:Vector.<Number>;
		private var angStep:Number;
		private var posStep:Number;
		private var curl:Number;
		private var n:Number = 0;
		private var a:Number = Math.random() * Math.PI * 2;
		private var _index:int;
		private var _g:Graphics;

		public function Spore()
		{
			_posX = new Vector.<Number>( LENGTH, true );
			_posY = new Vector.<Number>( LENGTH, true );
			_g = graphics;
			this.generate( range( 0.01, 0.05 ), range( 2.0, 3.0 ), range( 0.2, 1.0 ) );
		}

		public function generate( aStep:Number, pStep:Number, c:Number ):void
		{
			_index = 0;
			angStep = aStep;
			posStep = pStep;
			curl = c;
			var loc:Point = new Point( 0, 0 );
			while( _index < LENGTH )
			{
				n += Math.random() * (angStep - -angStep) + -angStep;
				n *= 0.9 + curl * 0.1;
				a += n;
				loc.x += Math.cos( a ) * posStep;
				loc.y += Math.sin( a ) * posStep;
				_posX[ _index ] = loc.x;
				_posY[ _index ] = loc.y;
				_index++;
			}
			_index = 0;
		}
		public function step():void
		{
			_g.clear();
			_g.lineStyle( 0, 0x000000, 0.7 );
			var c:int = 0;
			var radius:Number;
			while( c < _index )
			{
				radius = _index / c;
				if( radius > 10 ) radius = 10;
				_g.beginFill( 0xFF6600, 0.4 );
				_g.drawCircle( _posX[ c ], _posY[ c ], radius );
				_g.endFill();
				c++;
			}
			_index++;
			if( _index >= LENGTH )
			{
				this.generate( range( 0.01, 0.05 ), range( 2.0, 3.0 ), range( 0.2, 1.0 ) );
			}
		}
		private function range(min:Number, max:Number = NaN):Number
		{
			if(isNaN(max)) {max = min; min = 0}
				return min + (Math.random() * (max - min));
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rickigregersen.com/2009/08/08/growing-homegrown-tentacles/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>RandomWalk</title>
		<link>http://www.rickigregersen.com/2009/08/06/randomwalk/</link>
		<comments>http://www.rickigregersen.com/2009/08/06/randomwalk/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 18:32:55 +0000</pubDate>
		<dc:creator>Ricki</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Particle]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[flash builder 4]]></category>

		<guid isPermaLink="false">http://www.rickigregersen.com/?p=180</guid>
		<description><![CDATA[Im looking into some of the random walk stuff out there and I stumbled upon www.actionsnippet.com and his RandomWalk experiments, great site by the way, bring coffee. The thing that was cool about his way of doing it was that he constrains the &#8220;walkers&#8221; to only move: up, down, left and right. Absolutely no diagonal [...]]]></description>
			<content:encoded><![CDATA[<p>Im looking into some of the random walk stuff out there and I stumbled upon <a href="http://www.actionsnippet.com">www.actionsnippet.com</a> and his RandomWalk experiments, great site by the way, bring coffee.<br />
The thing that was cool about his way of doing it was that he constrains the &#8220;walkers&#8221; to only move: up, down, left and right. Absolutely no diagonal movement. This produces a strange grid looking pattern.</p>
<p><object width="512" height="512" data="http://www.rickigregersen.com/wp-content/uploads/RandomWalk.swf" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="scale" value="exactfit" /><param name="salign" value="l" /><param name="wmode" value="transparent" /><param name="src" value="http://www.rickigregersen.com/wp-content/uploads/RandomWalk.swf" /></object></h4>
<p>The code:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #11740a; font-style: italic;">/*&lt;pre lang=&quot;actionscript&quot;&gt;*/</span><br />
<span style="color: #11740a; font-style: italic;">//playing around with something Zevan Rosser from http://actionsnippet.com/?p=1236 did</span><br />
<span style="color: #11740a; font-style: italic;">//on his blog</span><br />
<br />
<span style="display:block;background-color:#ffff66">package <span style="color: #002200;">&#123;</span><br /></span>&nbsp; &nbsp; <br />
&nbsp; &nbsp; import flash.display.<span style="color: #002200;">*</span>;<br />
<span style="display:block;background-color:#ffff66">&nbsp; &nbsp; import flash.events.<span style="color: #002200;">*</span>;<br /></span>&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #002200;">&#91;</span>SWF<span style="color: #002200;">&#40;</span> width<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;512&quot;</span>, height <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">&quot;512&quot;</span>, backgroundColor <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">&quot;0x222222&quot;</span>, frameRate <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">&quot;120&quot;</span> <span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; public class RandomWalk extends Sprite <br />
<span style="display:block;background-color:#ffff66">&nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br /></span>&nbsp; &nbsp; &nbsp; &nbsp; private var _canvas<span style="color: #002200;">:</span>BitmapData;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private var _count<span style="color: #002200;">:</span><span style="color: #a61390;">int</span> <span style="color: #002200;">=</span> <span style="color: #2400d9;">100</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; private var _movers<span style="color: #002200;">:</span>Vector.&lt;Mover&gt;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; public function RandomWalk<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var w<span style="color: #002200;">:</span>Number <span style="color: #002200;">=</span> <span style="color: #2400d9;">512</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var h<span style="color: #002200;">:</span>Number <span style="color: #002200;">=</span> <span style="color: #2400d9;">512</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scaleX<span style="color: #002200;">=</span>scaleY <span style="color: #002200;">=</span> <span style="color: #2400d9;">0.25</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _canvas <span style="color: #002200;">=</span> new BitmapData<span style="color: #002200;">&#40;</span> w <span style="color: #002200;">*</span> <span style="color: #2400d9;">4</span>, h <span style="color: #002200;">*</span> <span style="color: #2400d9;">4</span>, <span style="color: #a61390;">false</span>, 0x222222 <span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addChild<span style="color: #002200;">&#40;</span> new Bitmap<span style="color: #002200;">&#40;</span> _canvas <span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _movers <span style="color: #002200;">=</span> new Vector.&lt;Mover&gt;<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span> var i<span style="color: #002200;">:</span><span style="color: #a61390;">int</span> <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; i &lt; _count; i<span style="color: #002200;">++</span> <span style="color: #002200;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _movers<span style="color: #002200;">&#91;</span> i <span style="color: #002200;">&#93;</span> <span style="color: #002200;">=</span> new Mover<span style="color: #002200;">&#40;</span> _canvas, w <span style="color: #002200;">*</span> <span style="color: #2400d9;">1.5</span> <span style="color: #002200;">+</span> Math.random<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">*</span> w, h <span style="color: #002200;">*</span> <span style="color: #2400d9;">1.5</span> <span style="color: #002200;">+</span> Math.random<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">*</span> h <span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addEventListener<span style="color: #002200;">&#40;</span> Event.ENTER_FRAME, onRun <span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; private function onRun<span style="color: #002200;">&#40;</span> evt<span style="color: #002200;">:</span>Event <span style="color: #002200;">&#41;</span><span style="color: #002200;">:</span><span style="color: #a61390;">void</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span>var i<span style="color: #002200;">:</span><span style="color: #a61390;">int</span> <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; i &lt; <span style="color: #2400d9;">200</span>; i<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span>var j<span style="color: #002200;">:</span><span style="color: #a61390;">int</span> <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; j &lt; _count; j<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _movers<span style="color: #002200;">&#91;</span> j <span style="color: #002200;">&#93;</span>.run<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span><br />
<br />
import flash.display.BitmapData;<br />
class Mover <br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; public var x<span style="color: #002200;">:</span>Number;<br />
&nbsp; &nbsp; public var y<span style="color: #002200;">:</span>Number;<br />
&nbsp; &nbsp; public var velX<span style="color: #002200;">:</span>Number;<br />
&nbsp; &nbsp; public var velY<span style="color: #002200;">:</span>Number;<br />
&nbsp; &nbsp; public var speed<span style="color: #002200;">:</span>Number;<br />
&nbsp; &nbsp; private var _canvas<span style="color: #002200;">:</span>BitmapData;<br />
&nbsp; &nbsp; private var _color<span style="color: #002200;">:</span>uint;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; public function Mover<span style="color: #002200;">&#40;</span> canvas<span style="color: #002200;">:</span>BitmapData, xp<span style="color: #002200;">:</span>Number, yp<span style="color: #002200;">:</span>Number <span style="color: #002200;">&#41;</span> <br />
&nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _color <span style="color: #002200;">=</span> 0xFF6600;<span style="color: #11740a; font-style: italic;">//Math.random() * 0xFFFFFF;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; _canvas <span style="color: #002200;">=</span> canvas;<br />
&nbsp; &nbsp; &nbsp; &nbsp; x <span style="color: #002200;">=</span> xp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; y <span style="color: #002200;">=</span> yp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; velX <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; velY <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; speed<span style="color: #002200;">=</span>Math.random<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">*</span> <span style="color: #2400d9;">5</span> <span style="color: #002200;">-</span> <span style="color: #2400d9;">2.5</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; public function run<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">:</span><span style="color: #a61390;">void</span> <br />
&nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; x <span style="color: #002200;">+=</span> velX;<br />
&nbsp; &nbsp; &nbsp; &nbsp; y <span style="color: #002200;">+=</span> velY;<br />
&nbsp; &nbsp; &nbsp; &nbsp; _canvas.setPixel<span style="color: #002200;">&#40;</span> x, y, _color <span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; var dir<span style="color: #002200;">:</span>Number <span style="color: #002200;">=</span> <span style="color: #a61390;">int</span><span style="color: #002200;">&#40;</span> Math.random<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">*</span> <span style="color: #2400d9;">4</span> <span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>dir <span style="color: #002200;">==</span> <span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; velX <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; velY <span style="color: #002200;">=-</span> speed;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>dir <span style="color: #002200;">==</span> <span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; velX <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; velY <span style="color: #002200;">=</span> speed;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>dir <span style="color: #002200;">==</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; velX <span style="color: #002200;">=-</span> speed;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; velY <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">else</span> <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>dir <span style="color: #002200;">==</span> <span style="color: #2400d9;">3</span><span style="color: #002200;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; velX <span style="color: #002200;">=</span> speed;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; velY <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #11740a; font-style: italic;">/*&lt;/pre&gt;*/</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.rickigregersen.com/2009/08/06/randomwalk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Homegrown Tentacles</title>
		<link>http://www.rickigregersen.com/2009/08/06/homegrown-tentacles/</link>
		<comments>http://www.rickigregersen.com/2009/08/06/homegrown-tentacles/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 18:03:40 +0000</pubDate>
		<dc:creator>Ricki</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Particle]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[Filters]]></category>
		<category><![CDATA[flash builder 4]]></category>
		<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://www.rickigregersen.com/?p=173</guid>
		<description><![CDATA[I had been scurrying about over on the Soulwire blog, again, and looking at the tentacles. I did some experiments of my own, but the tentacles never came out right, not organic enough. I wrote Justin and asked him how he did it and he was really cool about helping out with a code example [...]]]></description>
			<content:encoded><![CDATA[<p>I had been scurrying about over on the Soulwire blog, again, and looking at the tentacles. I did some experiments of<br />
my own, but the tentacles never came out right, not organic enough. I wrote Justin and asked him how he did it and he was really cool about helping out with a code example of how he did that part.</p>
<p>The Soulwire Tentacles was an experiment in PixelBender speed and usability, so he makes it look as if the tentacles are really growing, i.e. starts out small and each &#8220;joint&#8221; grows as the tentacles grows. Mine is just a look into the random-organic way they grow. Also I was trying to see what kinds of speed I would get by using the Bitmap approach.</p>
<p>Here are the <a href="http://blog.soulwire.co.uk/flash/actionscript-3/pixel-bender-growing-tentacles/">Soulwire Tentacles</a></p>
<p>And here are my Tentacles&#8230; that came out wrong&#8230; <img src='http://www.rickigregersen.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><object width="512" height="512" data="http://www.rickigregersen.com/wp-content/uploads/BitmapSpore.swf" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="scale" value="exactfit" /><param name="salign" value="l" /><param name="wmode" value="transparent" /><param name="src" value="http://www.rickigregersen.com/wp-content/uploads/BitmapSpore.swf" /></object></h4>
<p>The code:</p>
<pre lang="actionscript">
/**
*
 * @BitmapSpore.as	:	inspired by http://blog.soulwire.co.uk/flash/actionscript-3/pixel-bender-growing-tentacles/
 * @Date  08/06-09
 * @Ricki Gregersen
*/

package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.BlurFilter;
	import flash.geom.ColorTransform;
	import flash.geom.Point;

	[SWF( width="512", height = "512", backgroundColor = "0x222222", frameRate = "30" )]

	public class BitmapSpore extends Sprite
	{
		private static var fading : ColorTransform = new ColorTransform( 1, 1, 1, 0.99999 );
		private static var _blur : BlurFilter = new BlurFilter( 1, 1, 2 );

		private var _bmd:BitmapData;
		private var _bmp:Bitmap;
		private var _container:Sprite;

		public function BitmapSpore()
		{
			_bmd = new BitmapData( 512, 512, true, 0x222222 );
			_bmp = new Bitmap( _bmd );
			addChild( _bmp );
			var s:Spore;
			addChild( _container = new Sprite() );
			for( var i:int = 0; i < 500; i++ )
			{
				s = new Spore( 256, 256, range( 0.01, 0.05 ), range( 2.0, 3.0 ), range( 0.2, 1.0 ));
				s.scaleX = s.scaleY = Math.random() * 2;
				_container.addChild( s );
			}
			addEventListener( Event.ENTER_FRAME, update );
		}

		private function update( event:Event ):void
		{
			var n:int = _container.numChildren;
			var s:Spore;

			for( var i:int = 0; i < n; i++ )
			{
				s = Spore( _container.getChildAt( i ));
				s.move();
				s.x = s.loc.x;
				s.y = s.loc.y;
			}
			_bmp.filters = [  _blur ];
			_bmd.colorTransform( _bmd.rect, fading );
			_bmd.draw( _container );
		}

		private function range(min:Number, max:Number = NaN):Number
		{
			if(isNaN(max)) {max = min; min = 0}
				return min + (Math.random() * (max - min));
		} 

	}
}
	import flash.geom.Point;
	import flash.display.Shape;

	class Spore extends Shape
	{
		public var loc:Point;

		private var angStep:Number;
		private var posStep:Number;
		private var curl:Number;
		private var n:Number = 0;
		private var a:Number = Math.random() * Math.PI * 2;

		function Spore( xPos:Number, yPos:Number, aStep:Number, pStep:Number, c:Number )
		{
			loc = new Point( xPos, yPos );
			angStep = aStep;
			posStep = pStep;
			curl = c;
			graphics.lineStyle( 0, 0x222222, 0.7 );
			graphics.beginFill( 0xFF6600, 0.7 );
			graphics.drawCircle( 0, 0, 5 );
			graphics.endFill();
		}
		public function move():void
		{
			n += Math.random() * (angStep - -angStep) + -angStep;
			n *= 0.9 + curl * 0.1;
			a += n;
			loc.x += Math.cos( a ) * posStep;
			loc.y += Math.sin( a ) * posStep;
			this.scaleX = this.scaleY *= 0.98;
			var s:Number = this.scaleX = this.scaleY;
			if( s < 0.1 )
			{
				loc.x = loc.y = 256;
				this.scaleX = this.scaleY = Math.random() * 2;
			}
		}
	}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rickigregersen.com/2009/08/06/homegrown-tentacles/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>More camera flow field fun</title>
		<link>http://www.rickigregersen.com/2009/06/16/more-camera-flow-field-fun/</link>
		<comments>http://www.rickigregersen.com/2009/06/16/more-camera-flow-field-fun/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 20:10:06 +0000</pubDate>
		<dc:creator>Ricki</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flow field]]></category>
		<category><![CDATA[vectors]]></category>
		<category><![CDATA[web cam]]></category>

		<guid isPermaLink="false">http://www.rickigregersen.com/?p=159</guid>
		<description><![CDATA[Apparently I have not finished my little Flow Field craze, In one of my math books I saw a picture of a flow field as it is depicted in math terms, as a little grid of arrows. I thought it could be fun to play around with this idea. The code is really sloppy this [...]]]></description>
			<content:encoded><![CDATA[<p>Apparently I have not finished my little Flow Field craze, In one of my math books I saw a picture of a flow field<br />
as it is depicted in math terms, as a little grid of arrows. I thought it could be fun to play around with this idea.</p>
<p>The code is really sloppy this time, only took an hour or two, so I&#8217;ll post the example here along with the project (A Flash Builder Flash Project SDK 4.0 to be precise, will run in the Flash IDE, no problem).</p>
<h3>This is your brain, and this is your brain on vectors!</h3>
<h4>(Warning, this could potentially push your browser to the limit if you are to eager with the sliders. So please save any unfinished pulitzer price article you are currently working on in Google docs, I really don&#8217;t want to piss of anyone <img src='http://www.rickigregersen.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )<br />
<object width="490" height="550" data="http://www.rickigregersen.com/wp-content/uploads/VectorFlowField.swf" type="application/x-shockwave-flash"><param name="quality" value="medium" /><param name="scale" value="exactfit" /><param name="salign" value="l" /><param name="wmode" value="transparent" /><param name="src" value="http://www.rickigregersen.com/wp-content/uploads/VectorFlowField.swf" /></object></h4>
<p><a href="http://rickigregersen.com/wp-content/uploads/flowfieldAndMinimalComps.zip">Source is here, I included Bit-101&#8242;s minimalComps sine Im using that library, they are great for these things!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rickigregersen.com/2009/06/16/more-camera-flow-field-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Evil &amp; Loud Perlin noise</title>
		<link>http://www.rickigregersen.com/2009/05/28/evil-loud-perlin-noise/</link>
		<comments>http://www.rickigregersen.com/2009/05/28/evil-loud-perlin-noise/#comments</comments>
		<pubDate>Thu, 28 May 2009 18:42:54 +0000</pubDate>
		<dc:creator>Ricki</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[noise]]></category>
		<category><![CDATA[Perlin]]></category>

		<guid isPermaLink="false">http://www.rickigregersen.com/?p=122</guid>
		<description><![CDATA[In regards to my previous Perlin Flowfield post, it was a bit strange because I could simply not remember the basics about Perlin noise. Yes, as my colleague I falsely believed Perlin to be the evil brother of Merlin. I have previously used Perlin noise in Processing, it is a bit different in some of [...]]]></description>
			<content:encoded><![CDATA[<p>In regards to my previous <a href="http://www.rickigregersen.com/?p=93#content">Perlin Flowfield</a> post, it was a bit strange because I could simply not remember the basics about Perlin noise. Yes, as my colleague I falsely believed Perlin to be the evil brother of Merlin.</p>
<p>I have previously used Perlin noise in Processing, it is a bit different in some of the aspects of how you &#8220;access&#8221; it. In Processing you sort of get the values representing the noise iteration, whereas In Flash you actually build a noise Bitmap and read pixels from this to produce numerical noise. I Processing I guess you would do the opposite, i.e. building all the noise values into a bitmap to get something similar to the noise below.</p>
<p><object width="530" height="680" data="http://www.rickigregersen.com/wp-content/uploads/PerlinNoiseAdjust.swf" type="application/x-shockwave-flash"><param name="quality" value="medium" /><param name="scale" value="exactfit" /><param name="salign" value="l" /><param name="wmode" value="transparent" /><param name="src" value="http://www.rickigregersen.com/wp-content/uploads/PerlinNoiseAdjust.swf" /></object></p>
<p>So I build this little app to play around with the parameters and to see how much detail one can get away with, before the calculation load gets to heavy for practical use. The values that can be adjusted below are those that go into the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html#perlinNoise()">BitmapData.perlinNoise method</a> If you would like to put in more controls or whatever you feel like doing with this small app then: <a href="http://www.rickigregersen.com/wp-content/uploads/PerlinAdjuster.zip">Snatch the entire Flex project here (SDK 3.3)</a>, swf included.</p>
<p>I recalled that when dabbling with Perlin noise, a year ago, in Processing I found <a href="http://www.noisemachine.com/talk1/">Ken Perlin&#8217;s talk on&#8230; well, noise I guess <img src='http://www.rickigregersen.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </a> It is very interesting and even though words like <em>permutations</em> and <em>fractals</em> are used to some extend it is mainly an interesting story about this invention. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rickigregersen.com/2009/05/28/evil-loud-perlin-noise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
