<?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; Snippets</title>
	<atom:link href="http://blog.chrisherring.co.uk/category/snippets/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>The bit between pixels</title>
		<link>http://blog.chrisherring.co.uk/2009/10/19/the-bit-between-pixels/</link>
		<comments>http://blog.chrisherring.co.uk/2009/10/19/the-bit-between-pixels/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 21:53:31 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[pixels]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=738</guid>
		<description><![CDATA[A little Actionscript 3.0 function to help to find those DisplayObjects in Flash which are placed on half pixels and then snap them back into place. Although you can just leave them floating on half pixels if you want! private function displayListSnapper(container:DisplayObjectContainer, round:Boolean, debug:Boolean, indent:String = ""):void { var child:DisplayObject; for (var i:uint=0; i < [...]]]></description>
			<content:encoded><![CDATA[<p>
A little Actionscript 3.0 function to help to find those DisplayObjects in Flash which are placed on half pixels and then snap them back into place. Although you can just leave them floating on half pixels if you want!
</p>
<p><code><br />
private function displayListSnapper(container:DisplayObjectContainer, round:Boolean, debug:Boolean, indent:String = ""):void<br />
{<br />
  var child:DisplayObject;<br />
  for (var i:uint=0; i < container.numChildren; i++)<br />
  {<br />
    child = container.getChildAt(i);</p>
<p>	if(round == true)<br />
	{<br />
     child.x = Math.round(child.x);<br />
     child.y = Math.round(child.y);<br />
	}</p>
<p>	if(debug == true)<br />
	{<br />
	 trace(indent + "DisplayObject: " +child + ":: Name: " +  child.name + " :: x:" + child.x + " :: y:" + child.y);<br />
	}</p>
<p>	if (container.getChildAt(i) is DisplayObjectContainer)<br />
	{<br />
	 roundDisplayList(DisplayObjectContainer(child), round, debug, indent + "^^^")<br />
	}<br />
  }<br />
}</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/10/19/the-bit-between-pixels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>Shuffle Shuffle Array</title>
		<link>http://blog.chrisherring.co.uk/2009/07/21/shuffle-shuffle-array/</link>
		<comments>http://blog.chrisherring.co.uk/2009/07/21/shuffle-shuffle-array/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 22:04:39 +0000</pubDate>
		<dc:creator>blog.chrisherring.co.uk</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[shuffle]]></category>

		<guid isPermaLink="false">http://blog.chrisherring.co.uk/?p=415</guid>
		<description><![CDATA[Some projects you find yourself needing to shuffle arrays to randomise the objects within, below is a little static function for Actionscript 3 which will do the above. In order to use the function you need to do the following&#8230; toBeShuffledArray = ArrayShuffle.shuffle(toBeShuffledArray); public class ArrayShuffle() { public static function shuffle(array:Array):Array { var obj:*; var [...]]]></description>
			<content:encoded><![CDATA[<p>Some projects you find yourself needing to shuffle arrays to randomise the objects within, below is a little static function for Actionscript 3 which will do the above. In order to use the function you need to do the following&#8230;</p>
<p><code>toBeShuffledArray = ArrayShuffle.shuffle(toBeShuffledArray);</code></p>
<p><code><br />
public class ArrayShuffle()<br />
{<br />
    public static function shuffle(array:Array):Array<br />
    {<br />
        var obj:*;<br />
        var ran:Number;</p>
<p>        for(var i:Number = 0; i<array.length; i++)<br />
        {<br />
             obj = array[i];<br />
             ran = Math.floor(Math.random() * array.length);<br />
             array[i] = array[ran];<br />
             array[ran] = obj;<br />
        }<br />
        return array;<br />
    }</p>
<p>}<br />
</code></p>
<p><a href="http://blog.chrisherring.co.uk/wp-content/code/ArrayShuffle.as">Source code</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chrisherring.co.uk/2009/07/21/shuffle-shuffle-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

