<?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; actionscript</title>
	<atom:link href="http://blog.chrisherring.co.uk/tag/actionscript/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>Facebook API: Who and your App?</title>
		<link>http://blog.chrisherring.co.uk/2009/08/25/facebook-api-who-and-your-app/</link>
		<comments>http://blog.chrisherring.co.uk/2009/08/25/facebook-api-who-and-your-app/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 16:24:54 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=707</guid>
		<description><![CDATA[When creating a Facebook App with the Adobe Flash Facebook API, it&#8217;s pretty useful to know which of the users friends, has also added your Facebook App for scoreboards etc. A simple FacebookCall using GetAppUsers and then interpreting the returned data with GetAppUserData can yield an array of UID&#8217;s or raw XML. The code below [...]]]></description>
			<content:encoded><![CDATA[<p>
When creating a Facebook App with the Adobe Flash Facebook API, it&#8217;s pretty useful to know which of the users friends, has also added your Facebook App for scoreboards etc. A simple <a target="_blank" href=" http://facebook-actionscript-api.googlecode.com/svn/release/current/docs/com/facebook/net/FacebookCall.html">FacebookCall </a>using <a target="_blank" href="http://facebook-actionscript-api.googlecode.com/svn/release/current/docs/com/facebook/commands/friends/GetAppUsers.html">GetAppUsers </a>and then interpreting the returned data with <a target="_blank" href="http://facebook-actionscript-api.googlecode.com/svn/release/current/docs/com/facebook/data/friends/GetAppUserData.html">GetAppUserData </a>can yield an array of UID&#8217;s or raw XML. The code below needs a valid Facebook session. </p>
<p><code><br />
private function getAppUsers():void<br />
{<br />
	var call:FacebookCall = facebook.post(new GetAppUsers());<br />
	call.addEventListener(FacebookEvent.COMPLETE, this.callCompleteHandler);<br />
}</p>
<p>private function callCompleteHandler(event:FacebookEvent):void<br />
{<br />
	event.target.removeEventListener(FacebookEvent.COMPLETE, this.callCompleteHandler);<br />
	var appUserData:GetAppUserData = event.data as GetAppUserData;</p>
<p>	trace(appUserData + " :: uids :      " + appUserData.uids)<br />
	trace(appUserData + " :: RawResult : " + appUserData.rawResult)<br />
}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/08/25/facebook-api-who-and-your-app/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<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>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>
	</channel>
</rss>

