<?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>Chris Herring &#187; Experiments</title>
	<atom:link href="http://blog.chrisherring.co.uk/category/experiments/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.chrisherring.co.uk</link>
	<description>Interaction, development and everything in between...</description>
	<lastBuildDate>Thu, 10 Mar 2011 09:34:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Sequential Randomness</title>
		<link>http://blog.chrisherring.co.uk/2009/08/20/sequential-randomness/</link>
		<comments>http://blog.chrisherring.co.uk/2009/08/20/sequential-randomness/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 15:48:49 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[Effects]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Perlin Noise]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=649</guid>
		<description><![CDATA[Perlin Noise can be a great way of adding some sequential random movement to an animation or an effect. Originally used in the used in the 1982 film Tron Perlin Noise is a procedural texture used by 3D Artists ever since to make large textures appear more natural. Although we&#8217;ve not going to start texturing [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Perlin Noise can be a great way of adding some sequential random movement to an animation or an effect. Originally used in the used in the 1982 film <a href="http://en.wikipedia.org/wiki/Tron_(film)" target="_blank">Tron</a> Perlin Noise is a procedural texture used by 3D Artists ever since to make large textures appear more natural.</p>
<p style="text-align: left;">
Although we&#8217;ve not going to start texturing large areas, what we can produce in Flash with Perlin Noise is controlled and sequential randomness. Don&#8217;t laugh. The first thing to do is generate a Perlin Noise image with the following line of AS3 code.
</p>
<p><code><br />
var pNoise:BitmapData = new BitmapData( 550, 75);<br />
pNoise.perlinNoise( 100, 80, 9, Math.random()*100, true, true )<br />
addChild(new  Bitmap(pNoise));<br />
</code></p>
<p style="text-align: left;">The above code generates a Perlin Nose image like this.</p>
<p style="text-align: center;"><img class="aligncenter" title="Perlin Noise " src="http://blog.chrisherring.co.uk/wp-content/uploads/images/perlin_noise_example.jpg" alt="" width="550" height="100" /></p>
<p style="text-align: left;">The next step is to get the pixel colour at 0, 0 on the Perlin Noise image, and convert it into a number. We can slowly move across the Perlin Noise image generating numbers which will form a pattern similar to this 0.62, 0.64, 0.66, 0.7, 0.66, 0.60, 0.58. The numerical pattern changes as the coloured clouds merge into each other, and due to this the pattern is sequential and coloured clouds controls the randomness. Therefore no anomalies are produced.</p>
<p style="text-align: left;">
Below I&#8217;ve created a little Flash movie which draws a pixel line based upon the Perlin Noise. I&#8217;ve then multiplied this 4 times changing the colour and the result resembles a mountain stage in the Tour De France.
</p>
<p id="PerlinNoise" style="margin-left:15px; text-align: left;">Flash is displayed here</p>
<p><script src="http://blog.chrisherring.co.uk/wp-content/js/swfobject.js" type="text/javascript"></script> <script type="text/javascript"><!--
var s6 = new SWFObject('http://blog.chrisherring.co.uk/wp-content/experiments/perlin_noise/perlin_noise.swf','player','550','100','9', '#eaeaea');
s6.addVariable("basePath", "http://blog.chrisherring.co.uk/wp-content/experiments/perlin_noise/")
s6.write('PerlinNoise');
// --></script></p>
<p style="text-align: left;">Perlin Noise for controlled and sequential randomness!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/08/20/sequential-randomness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Painting with Particles</title>
		<link>http://blog.chrisherring.co.uk/2009/07/29/painting-with-particles/</link>
		<comments>http://blog.chrisherring.co.uk/2009/07/29/painting-with-particles/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 09:14:55 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash. flint particle system]]></category>
		<category><![CDATA[flint]]></category>
		<category><![CDATA[particle]]></category>
		<category><![CDATA[particles]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=599</guid>
		<description><![CDATA[Painting with Particles is a mini Flash/ Actionscript 3 project I produced using the Flint Particle system. I came across Flint a few months ago because of its incredible smoke effects, and after a few tests I thought I would have a crack at producing something slightly different. The main reason behind creating a simple [...]]]></description>
			<content:encoded><![CDATA[<p>Painting with Particles is a mini Flash/ Actionscript 3 project I produced using the <a title="Flint Particles system" href="http://flintparticles.org/" target="_blank">Flint Particle system</a>. I came across Flint a few months ago because of its incredible <a title="Flint Particles System Smoke" href="http://flintparticles.org/examples/fire-and-smoke" target="_blank">smoke effects</a>, and after a few tests I thought I would have a crack at producing something slightly different. The main reason behind creating a simple click/hold painting app was because of the interesting and unique effects you can create/ texturize with particles. Although this maybe not be evident from the examples I quickly put together below.</p>
<p style="margin-left:15px;"><img class="center" src="http://blog.chrisherring.co.uk/wp-content/uploads/images/painting_with_particles_examples.jpg" alt="Painting with Particles Examples" /></p>
<p style="margin-left:15px;">There a few little bugs with the build below and I&#8217;ve had to take a couple of features out for this post. The spray paint effect which followed the users mouse movement didn&#8217;t make the cut and I&#8217;m yet to get the color management right due to hex code to uint conversion issue. For once I haven&#8217;t really got much to say about Painting with Particles, other then have a Paint!</p>
<p id="PaintingParticles" style="margin-left:15px;">Flash is displayed here</p>
<p style="margin-left:15px;">
<p><script src="http://blog.chrisherring.co.uk/wp-content/js/swfobject.js" type="text/javascript"></script> <script type="text/javascript"><!--
var s5 = new SWFObject('http://blog.chrisherring.co.uk/wp-content/experiments/painting_particles/swf/App.swf','player','550','300','9', '#eaeaea');
s5.addVariable("basePath", "http://blog.chrisherring.co.uk/wp-content/experiments/painting_particles/")
s5.write('PaintingParticles');
// --></script></p>
<p>Just a quick example of the actionscript code used to create a Fill emitter<br />
<code><br />
public static function get fill():Emitter2D<br />
{<br />
	var emitter:Emitter2D;<br />
	emitter = new Emitter2D();<br />
	emitter.counter = new Steady(10000);<br />
	emitter.addInitializer( new ColorInit(ComponentManager.colour1, ComponentManager.colour2) );<br />
	emitter.addInitializer( new Position( new DiscZone( new Point( AppConstants.APP_WIDTH/2, AppConstants.APP_HEIGHT/2),  AppConstants.APP_WIDTH ) ) );<br />
	emitter.addAction( new BoundingBox(0, 0, AppConstants.APP_WIDTH, AppConstants.APP_HEIGHT ) );<br />
	return emitter;<br />
}<br />
</code></p>
<p style="margin-left:15px;"><strong>Related links</strong><br />
- Flint Particle System <a title="Flint Particles Blog" href="http://flintparticles.org/blog/" target="_blank">blog</a><br />
- <a title="Getting started with Flint Particles system" href="http://flintparticles.org/tutorials/snowfall" target="_blank">Getting started</a> with Flint Particle System</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/07/29/painting-with-particles/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Faceflash Facebook</title>
		<link>http://blog.chrisherring.co.uk/2009/07/28/faceflash-facebook/</link>
		<comments>http://blog.chrisherring.co.uk/2009/07/28/faceflash-facebook/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 13:04:35 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=524</guid>
		<description><![CDATA[So Adobe and Facebook came together a few months ago and released a full blown API for Flash/Actionscript 3, well released maybe more re-branded an existing API by Jason Crist. Anyway the API is very detailed, and as far as I aware well documented. Thought after a few weeks it&#8217;s probably worth looking into, as [...]]]></description>
			<content:encoded><![CDATA[<p>So Adobe and Facebook came together a few months ago and released a full blown API for <a href="http://www.adobe.com/devnet/facebook/" target="_blank">Flash/Actionscript 3</a>, well released maybe more re-branded an existing API  by <a href="http://pbking.com/blog/" target="_blank">Jason Crist</a>. Anyway the API is very detailed, and as far as I aware well <a href="http://facebook-actionscript-api.googlecode.com/svn/release/current/docs/index.html" target="_blank">documented</a>. Thought after a few weeks it&#8217;s probably worth looking into, as Facebook is still a buzzword which still holds a lot of weight.</p>
<p>In my opinion there are two types of application which will use the Facebook Flash API, the first being get and display apps. These are applications which get a users data and display information, think of the Last FM widget which display your top songs. Secondly an applications which take advantage of Facebook&#8217;s networking ability like Connect Red Bull. No doubt there are probably more types of application but there&#8217;s nothing like making a wide sweeping statement!</p>
<p style="margin-left:15px;"><img class="center" title="Facebook Preview" src="http://blog.chrisherring.co.uk/wp-content/uploads/images/facebook_noflash.jpg" alt="" width="550" height="390" /></p>
<p>Anyway I&#8217;m just going mention a couple of things, about this little get and display application I&#8217;ve quickly made which gathers list of the users friends and displays specific information. Below I have briefly listed the various steps in the process to get this information, as you can see the process is unlike other API&#8217;s which after making a call send you back an xml document of information. For instance twitter will give a xml document containing all your friends information. Instead with the Facebook API you make request for a friends list, get a list of unique id&#8217;s in return and then have to make individual user queries on the unique id&#8217;s. I imagine I&#8217;ve completely missed something here, but I may be right if this is the case it&#8217;s probably due to the scale of Facebook, the data available and the potentially security risk. Making individual user queries also means the amount of being data requested is smaller i.e you receive only what ask for.</p>
<p>&nbsp; &nbsp;1. User logins into Facebook<br />
&nbsp; &nbsp;2. User confirms login<br />
&nbsp; &nbsp;3. Start Facebook session<br />
&nbsp; &nbsp;4. Fetch users friends with users unique id<br />
&nbsp; &nbsp;5. Receive  unique id of users friends<br />
&nbsp; &nbsp;6. Fetch specific data for each of the users friends<br />
&nbsp; &nbsp;7. Receive data for each of the users friends<br />
&nbsp; &nbsp;8. Repeat 6 and 7 till complete<br />
&nbsp; &nbsp;9. Do whatever.</p>
<p>The little application I&#8217;ve produced, just displays a selected number of the Facebook user friends and some basic information name, picture, DOB, about me. Perhaps next time I&#8217;ll try some networking and add some error handling. Here&#8217;s the application.</p>
<p id="Facebook" style="margin-left:15px;">Flash is displayed here</p>
<p><script src="http://blog.chrisherring.co.uk/wp-content/js/swfobject.js" type="text/javascript"></script> <script type="text/javascript"><!--
var s4 = new SWFObject('http://blog.chrisherring.co.uk/wp-content/experiments/facebook/swf/facebook_board.swf','player','550','390','9');
s4.addVariable("basePath", "http://blog.chrisherring.co.uk/wp-content/experiments/facebook/")
s4.write('Facebook');
// --></script></p>
<p>And now some actionscript code.</p>
<p>By this stage the user has initialized the Facebook session by logging into Facebook, then confirmed they have done so and I have Completed a FriendList Request. Below I&#8217;m pushing all the unique id&#8217;s into an array, so they&#8217;re slightly more accessible then shuffling the array so I have a random order of friends each time.<br />
<code><br />
private function getFriendsInfoResponse(event:FacebookEvent):void<br />
{<br />
    event.target.removeEventListener(FacebookEvent.COMPLETE, this.getFriendsInfoResponse);</p>
<p>    var responseData:GetFriendsData = event.data as GetFriendsData;</p>
<p>    for(var i:Number = 0; i<responseData.friends.length; i++)<br />
    {<br />
       this.uniIdArray.push(responseData.friends.getItemAt(i).uid);<br />
    }</p>
<p>    ArrayShuffle.shuffle(this.uniIdArray);<br />
    this.loadFriend();<br />
}<br />
</code></p>
<p>Simple load request of a user's data by via a unique id.</p>
<p><code><br />
private function loadFriend():void<br />
{<br />
    var call:FacebookCall = facebook.post(new GetInfo([this.uniIdArray[this.loadCount]], ['uid', first_name',   'last_name',    'pic_small',  'about_me', 'birthday']));<br />
    call.addEventListener(FacebookEvent.COMPLETE, this.getFriendInfoResponse);<br />
}<br />
</code></p>
<p>I've created an ProfileObject class, which consists of various getters and setters for the requested data. And I know I've declared variables halfway into a function, but the first few lines handle errors. </p>
<p><code><br />
private function getFriendInfoResponse(event:FacebookEvent):void<br />
{<br />
    event.target.removeEventListener(FacebookEvent.COMPLETE, this.getFriendInfoResponse);</p>
<p>    if (!responseData || event.error)<br />
    {<br />
        trace("error ::" + this.loadCount);<br />
	this.loadFriend();<br />
	return;<br />
    }	</p>
<p>    var responseData:GetInfoData = event.data as GetInfoData;<br />
    var profileObj:ProfileObject = new ProfileObject();</p>
<p>    profileObj.uid = responseData.userCollection.getItemAt(0).uid;<br />
    profileObj.firstName = responseData.userCollection.getItemAt(0).first_name;<br />
    profileObj.lastName = responseData.userCollection.getItemAt(0).last_name;<br />
    profileObj.profilePic = responseData.userCollection.getItemAt(0).pic_small;<br />
    profileObj.aboutMe = responseData.userCollection.getItemAt(0).about_me;<br />
    profileObj.brithday = responseData.userCollection.getItemAt(0).birthday;<br />
    this.profileArray.push(profileObj);<br />
}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/07/28/faceflash-facebook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Placing Particles</title>
		<link>http://blog.chrisherring.co.uk/2009/07/27/placing-particles/</link>
		<comments>http://blog.chrisherring.co.uk/2009/07/27/placing-particles/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 09:07:51 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[papervision]]></category>
		<category><![CDATA[particles particles]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=481</guid>
		<description><![CDATA[Papervision is great but I sometimes feel that I would be a lot better off with a greater understanding of 3D Math. Therefore this post based upon an experiment I did a little while ago, with the aim of generating a sphere of particles and improving my 3D Math. The following picture is close to [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Papervision" href="http://blog.papervision3d.org/" target="_blank">Papervision </a>is great but I sometimes feel that I would be a lot better off with a greater understanding of 3D Math. Therefore this post based upon an experiment I did a little while ago, with the aim of generating a sphere of particles and improving my 3D Math.</p>
<p>The following picture is close to what I intended to achieve, however due to the very high number of particles with the sphere Papervision struggles render it. In this case switching to <a title="Flint Particle System" href="http://flintparticles.org/" target="_blank">Flint</a>, and using their 3D particle system would probably be a better idea. </p>
<p style="margin-left:15px;"><img class="center" title="Particle Globe" src="http://blog.chrisherring.co.uk/wp-content/uploads/images/globe.gif" alt="" width="550" height="306" /></p>
<p>Time to get gritty! The block of code below creates a sphere of Particles. The for loops below increase in specified steps for latitude and longitude, unlike your normal for loop which counts from 0 to whatever in single increments this stepped process enables us to distribute the Particles at an even distance. The sine wave calculation Math.sin(lat*Math.PI/180) is important for placing the particles in a spherical shape. A positive sine wave multiplied by PI  divided by 180 creates us a semi-circle, combined with a negative <a title="Sine Wave" href="http://en.wikipedia.org/wiki/Sine_wave" target="_blank">sine wave</a> we get a full circle. With in the two for loops I&#8217;ve also added a random if statement so that Papervision doesn&#8217;t struggle to render a high number of Particles, but still keeps the shape of a high density particle sphere. It&#8217;s also worth noting that I&#8217;ve created a class which extends the Particle class in Paperivision called Dot,  to which I&#8217;m passing the calculated x y z values, these are then stored so that the Particles can be tweened from a random x y z to form a sphere. I&#8217;ve done this only for visual reasons!</p>
<p><code><br />
for (var lat:Number = -90; lat<90; lat+=(360/dens))<br />
{<br />
     var radius:Number = Math.cos(lat * Math.PI / 180) * size;<br />
     var circumference:Number = (2*Math.PI*radius);<br />
     var numberOfDots:Number = Math.floor(dens*circumference)/size;</p>
<p>     for (var long:Number = 0; long<360; long+=(360/numberOfDots))<br />
     {<br />
          if (Math.floor(Math.random()*8) == 1)<br />
          {<br />
               part =  new Dot(Math.cos(long*Math.PI/180)*radius,<br />
                                       Math.sin(lat*Math.PI/180)*size,<br />
                                       Math.sin(long*Math.PI/180)*radius );<br />
               this.particleArray.push(part);<br />
               this.particleHolder.addParticle(part);<br />
          }<br />
     }<br />
}<br />
</code><br />
Click below in order to activate the Flash movie.</p>
<p id="PlacingParticles" style="margin-left:15px;">The following is a no flash image</p>
<p><script src="http://blog.chrisherring.co.uk/wp-content/js/swfobject.js" type="text/javascript"></script> <script type="text/javascript"><!--
var s3 = new SWFObject('http://blog.chrisherring.co.uk/wp-content/swf/PlacingParticles.swf','player','550','400','9'); s3.write('PlacingParticles');
// --></script></p>
<p>In end the outcome above is close to what I intended to achieve, however the density of the dots around the latitude axis is exactly the same at the poles as the equator. I've tried to resolve the density problem but without success, mainly due to Papervision struggling to render such a high density of Particles.  I'm realistically on the edge of Math skills and perhaps purchasing a 3D Math primer would be a good idea.  Anyway this was an interesting experiment which I got very close to getting it right.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/07/27/placing-particles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>lineTo Art</title>
		<link>http://blog.chrisherring.co.uk/2009/07/22/lineto-art/</link>
		<comments>http://blog.chrisherring.co.uk/2009/07/22/lineto-art/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 21:45:11 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[art]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[drawing]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=450</guid>
		<description><![CDATA[Odosketch has been around for a few days now, and has been recently made S.O.T.D by FWA. Its a great little drawing tool where people are creating really impressive sketches, and the best bit being you can watch their drawings play back. I thought I&#8217;ll have a little attempt at trying to recreate one of [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;"><a href="http://sketch.odopod.com/" target="_blank">Odosketch</a> has been around for a few days now, and has been recently made S.O.T.D by FWA. Its a great little drawing tool where people are creating really <a href="http://sketch.odopod.com/sketches/60743" target="_blank">impressive sketches</a>, and the best bit being you can watch their drawings play back. I thought I&#8217;ll have a little attempt at trying to recreate one of their brushes in Flash using Actionscript 3</p>
<p>I found the most important thing to do is store the previous x and y positions of shape, so the next time the user moves the mouse, the shape being drawn starts from the last shape added. Coupled with a basic acceleration calculation, alpha channel + canvas texture and you are close to what has been produced for Odosketch. Conqusently some of the shapes created when your <span>graphics.lineTo </span>calculations are slightly out, produce abstract results like the following.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://blog.chrisherring.co.uk/wp-content/uploads/images/abstractArt.jpg" alt="AbstractArt" width="548" height="400" /></p>
<p>Click below in order to activate the Flash movie, and then click again to change brush colour.</p>
<p id="LineToArt" style="margin-left:15px;">Flash is displayed here</p>
<p>Always find the following line of actionscript code to be quite funny, like when do you need a random colour other then situations like these!?!</p>
<p><code>Math.random()*0xFFFFFF;</code><br />
<script src="http://blog.chrisherring.co.uk/wp-content/js/swfobject.js" type="text/javascript"></script> <script type="text/javascript"><!--
var s2 = new SWFObject('http://blog.chrisherring.co.uk/wp-content/swf/LineToArt.swf','player','550','400','9');
s2.write('LineToArt');
// --></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/07/22/lineto-art/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>workspace.cleanup();</title>
		<link>http://blog.chrisherring.co.uk/2009/07/17/workspacecleanup/</link>
		<comments>http://blog.chrisherring.co.uk/2009/07/17/workspacecleanup/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 11:08:14 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[papervision]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=394</guid>
		<description><![CDATA[My project workspace at home and at work is full of little experiments or mini projects which never get finished or tidied up, and consequently not seen. Therefore I&#8217;ve decided to do a little cleanup and post them up here in whatever state or standard they are. A couple of months ago I created a [...]]]></description>
			<content:encoded><![CDATA[<p>My project workspace at home and at work is full of little experiments or mini projects which never get finished or tidied up, and consequently not seen. Therefore I&#8217;ve decided to do a little cleanup and post them up here in whatever state or standard they are.</p>
<p>A couple of months ago I created a couple of classes to handle xml from Twitter for a potential flash feed thingy. The classes consisted of a model class which creates business objects like tweets and user, making the data easily mangaged/accessible within a project. Using these classes I&#8217;ve just added a bit of <a title="Papervision" href="http://blog.papervision3d.org/" target="_blank">Papervision</a>, the text is displayed via the <a title="Text3D" href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/typography/Text3D.html" target="_blank">Text3D</a> class which is really nice class if your project uses <a title="Helvetica" href="http://en.wikipedia.org/wiki/Helvetica" target="_blank">Helvetica</a> and some what devoid if it doesn&#8217;t.</p>
<p id="TwitterPV" style="margin-left:15px;">Flash is displayed here</p>
<p><script src="http://blog.chrisherring.co.uk/wp-content/js/swfobject.js" type="text/javascript"></script> <script type="text/javascript"><!--
var s3 = new SWFObject('http://blog.chrisherring.co.uk/wp-content/experiments/twitter/swf/App.swf','player','550','200','9');
s3.addVariable("basePath", "http://blog.chrisherring.co.uk/wp-content/experiments/twitter/")
s3.write('TwitterPV');
// --></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/07/17/workspacecleanup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Papervision: Mapping 2D in 3D</title>
		<link>http://blog.chrisherring.co.uk/2009/06/14/papervision-mapping-2d-in-3d/</link>
		<comments>http://blog.chrisherring.co.uk/2009/06/14/papervision-mapping-2d-in-3d/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 20:46:42 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[papervision]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=344</guid>
		<description><![CDATA[There are many ways to improve the performance of your Papervision application, and in my first blog post in a few months I&#8217;ll cover the technique of mapping a 2D sprite to an object in 3D Papervision. The main concept of this technique is two reduce the number of elements rendered in 3D to a [...]]]></description>
			<content:encoded><![CDATA[<p>There are many ways to improve the performance of your <a title="Papervision" href="http://blog.papervision3d.org/" target="_blank">Papervision</a> application, and in my first blog post in a few months I&#8217;ll cover the technique of mapping a 2D sprite to an object in 3D Papervision. The main concept of this technique is two reduce the number of elements rendered in 3D to a minimum, naturally this is only applicable to certain situations. The yellow triangle below is a standard Sprite, and by clicking upon it will map the triangle to a red particle within the rotating sphere.</p>
<p id="Mapping2Din3D" style="margin-left:15px;">Flash is displayed here</p>
<p><script src="http://blog.chrisherring.co.uk/wp-content/js/swfobject.js" type="text/javascript"></script> <script type="text/javascript"><!--
var s2 = new SWFObject('http://blog.chrisherring.co.uk/wp-content/swf/Mapping2Din3D.swf','player','550','400','9');
s2.write('Mapping2Din3D');
// --></script></p>
<p><span style="text-decoration: underline;">Step 1</span><br />
After setting up a basic Papervision environment with a sphere, the next thing to do is add a particle to the edge of the sphere. Within Papervision its not possible to just create a new <a title="Particle" href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/core/geom/renderables/Particle.html" target="_blank">Particle</a>, and it add it the scene, instead the <a title="Particles" href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/core/geom/Particles.html" target="_blank">Particle</a> must be added to an instantiation of the Particles class, which acts as holding container for a Particle. It is worth noting that thousands of individual Particles can be added to the Particles container and then added to the scene to be rendered.</p>
<p><code> var material = new ParticleMaterial(0xFF3333, 1);<br />
var particle = new Particle(material, 15);<br />
this.particles = new Particles();<br />
this.particles.x =-294.8020952990483;<br />
this.particles.z = -44.981004334405526;<br />
this.particles.y = 47.67005198611658;<br />
this.particles.addParticle(particle);<br />
this.sphere.addChild(this.particles);<br />
</code></p>
<p><span style="text-decoration: underline;">Step 2</span><br />
In order to map a 2D Sprite to a 3D object we need to calculate the 3D objects relative position in x and y to the screen. Luckily by adding the following line to the previous code block this functionally can be switched on. The method <a title="autoCalcScreenCoords" href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/objects/DisplayObject3D.html#autoCalcScreenCoords" target="_blank">autoCalcScreenCoords</a><span> is </span>available to any class which extends <a title="DisplayObject3D" href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/objects/DisplayObject3D.html" target="_blank">DisplayObject3D</a>, however user must be careful as extra calculations are made with the potential for a performance drop if used with out.</p>
<p><code> this.particles.autoCalcScreenCoords = true;<br />
</code></p>
<p><span style="text-decoration: underline;">Step 3</span><br />
The screen x and y are always calculated relative to the size of the viewport being used. I&#8217;ve added the following couple of lines of code, within the render EnterFrame only so that the 2D Sprite is always mapped to the 3D object but of course could exist elsewhere.</p>
<p><code> this.triangle.x = ( this.particles.screen.x ) + (this.viewport.width  / 2);<br />
this.triangle.y = ( this.particles.screen.y ) + (this.viewport.height / 2);</code></p>
<p>And that&#8217;s it, pretty basic stuff yet can still be very useful.</p>
<p><a href="http://blog.chrisherring.co.uk/wp-content/code/Mapping2Din3D.as">Source code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/06/14/papervision-mapping-2d-in-3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mapping Music: Part 2</title>
		<link>http://blog.chrisherring.co.uk/2009/01/16/mapping-music-part-2/</link>
		<comments>http://blog.chrisherring.co.uk/2009/01/16/mapping-music-part-2/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 11:24:18 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[lastfm]]></category>
		<category><![CDATA[mapping music]]></category>
		<category><![CDATA[maps]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=151</guid>
		<description><![CDATA[After getting slightly distracted with the makeover I gave this blog last week and getting stuck into other work this week, I managed to spend a few hours this morning working on my Google Maps and Last FM mashup. Not to much to report, although I did managed to calculate a chart for the most [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">After getting slightly distracted with the makeover I gave this blog last week and getting stuck into other work this week, I managed to spend a few hours this morning working on my Google Maps and Last FM mashup. Not to much to report, although I did managed to calculate a chart for the most popular artist across Europe. Initially I was slightly disappointed with the figures perhaps I was expecting plays in the millions. After some calculator consultation the total number of top ten plays at 3mins estimates at 2.53 years worth of music. Impressive. </p>
<p>One issue that has risen is the high number of requests made to the Last FM api in order to get the country specific data. The choice was between using the  27 European Unions member states, or  the 49 countries which exist geographically within Europe. For the moment I&#8217;ve gone with the later, and ignored the 1.4mb of requests needed to complete this, but due to the Last FM api there is no other way of fetching the relevant data. A consequence of this is that Europe looks far more busy and the chart below is more populated. </p>
<p><img class="aligncenter" src="http://blog.chrisherring.co.uk/wp-content/uploads/images/mapping_music_3.jpg" alt="" width="580" height="356" /></p>
<p style="text-align: left; "><span style="text-decoration: underline;"><a title="Mapping maps example" href="http://blog.chrisherring.co.uk/experiments/mappingmusic/part_2/index.html" target="_blank"><img class="aligncenter" title="Mapping Music" src="http://blog.chrisherring.co.uk/wp-content/uploads/images/mapping_music_2.jpg" alt="" width="580" height="356" /></a></span></p>
<p style="text-align: left; ">The above image shows the chart generated after each of the European Countries data has been collated. I was slightly frustrated that the feed from the <a href="http://www.last.fm/api/show?service=297" target="_blank">Last FM api</a> isn&#8217;t live or updated on daily basis, instead I believe its updated weekly. I have uploaded the above build of Mapping Music and can be viewed <a title="Mapping music example" href="http://blog.chrisherring.co.uk/experiments/mappingmusic/part_2/index.html" target="_blank">here</a>. </p>
<p><strong>Next<br />
<span style="font-weight: normal;">- Individual country charts<br />
- Comparison charts<br />
- Improve the interface<br />
- Look into a chart timeline.</span></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/01/16/mapping-music-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mapping Music: Part 1</title>
		<link>http://blog.chrisherring.co.uk/2009/01/05/mapping-music-part-1/</link>
		<comments>http://blog.chrisherring.co.uk/2009/01/05/mapping-music-part-1/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 19:59:23 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[lastfm]]></category>
		<category><![CDATA[mapping music]]></category>
		<category><![CDATA[maps]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=107</guid>
		<description><![CDATA[Mapping music is the title of a little project I started over the weekend, hopefully over the forthcoming days I shall be blogging on its development. The idea is to use information gathered via Last FM and the visualize this geographically for Europe using the Google Maps API for flash. In doing so I&#8217;ll try [...]]]></description>
			<content:encoded><![CDATA[<p>Mapping music is the title of a little project I started over the weekend, hopefully over the forthcoming days I shall be blogging on its development. The idea is to use information gathered via Last FM and the visualize this geographically for Europe using the <a href="http://code.google.com/apis/maps/documentation/flash/" target="_blank">Google Maps API</a> for flash. In doing so I&#8217;ll try to calculate the most popular artists across Europe and have fun learning something new. </p>
<p><strong>Structure </strong><br />
At the moment I have an xml file which contains a list of countries within the Europe, then for each country I have attributed a latitude and longitude value. This is represented in the image below with a blue dot. It is easy to notice some of the dots are not in the centre of the countries, a by product of <a title="http://www.batchgeocode.com/" href="http://" target="_blank">Batch Geocoder</a> which is rather good. </p>
<p>In order to collate the information from Last FM various API requests are made relating to each Country. On the edge of the image below, I have quickly displayed each Country and its most popular artist. </p>
<p><img class="aligncenter" title="mapping music" src="http://blog.chrisherring.co.uk/wp-content/uploads/images/mapping_music_1.jpg" alt="" width="480" height="296" /></p>
<p><strong>Next</strong><br />
- Add an interface of some sort<br />
- Figure out the most popular artist in Europe.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/01/05/mapping-music-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Tweet tweet flick!</title>
		<link>http://blog.chrisherring.co.uk/2008/12/07/83/</link>
		<comments>http://blog.chrisherring.co.uk/2008/12/07/83/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 20:09:35 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[chrisherring.co.uk]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=83</guid>
		<description><![CDATA[I&#8217;ve just added a little twitter ticker flickr thing on chrisherring.co.uk which looks at my Twitter posts and fetches related Flickr image. A while ago I created a Twitter badge in flash for an indies band website, only to find 3 weeks later Twitter changed their api due to a security issue. Later I re-created [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">I&#8217;ve just added a little twitter ticker flickr thing on <a href="http://www.chrisherring.co.uk" target="_blank">chrisherring.co.uk</a> which looks at my <a href="http://twitter.com/chrisherring" target="_blank">Twitter posts</a> and fetches related Flickr image. A while ago I created a Twitter badge in flash for an indies band website, only to find 3 weeks later Twitter changed their api due to a security issue. Later I re-created the Twitter badge in Jquery using JSON. For this little project I decided to use <a href="http://en.wikipedia.org/wiki/JSON" target="_blank">JSON</a> as my data format, which can be parsed in AS3. </p>
<p style="text-align: left;">Looping through my recent Twitter posts I search for question marks or full stops etc with a regular expression which looks like this /\!|\?|\.|\&#8230;|\*/.  Upon finding a matching character I extract the preceding word, and query the Flick api for images tagged with the preceding word, then place the tagged image in the background.  In order to work around the security issue which arises when using Twitter and Flash, I use php to quickly copy my json feed and parse the local copy into flash. Below are some examples</p>
<p style="text-align: center;"><img class="aligncenter" src="http://blog.chrisherring.co.uk/wp-content/uploads/images/twitter_flickr_1.jpg" alt="" width="480" height="213" /></p>
<p style="text-align: center;">
<p style="text-align: center;"><img class="alignnone" src="http://blog.chrisherring.co.uk/wp-content/uploads/images/twitter_flickr_2.jpg" alt="" width="480" height="213" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2008/12/07/83/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

