<?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>AdeCode &#187; AS3</title>
	<atom:link href="http://code.aderowbotham.com/category/as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://code.aderowbotham.com</link>
	<description>Ade as in Lemonade, Code as in Code</description>
	<lastBuildDate>Sun, 03 Jan 2010 15:27:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>StageAwareSprite</title>
		<link>http://code.aderowbotham.com/2010/01/stageawaresprite/</link>
		<comments>http://code.aderowbotham.com/2010/01/stageawaresprite/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 15:18:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[stage]]></category>

		<guid isPermaLink="false">http://code.aderowbotham.com/?p=49</guid>
		<description><![CDATA[Here&#8217;s another handy little object. Again, it&#8217;s pretty trivial but might save you 10 minutes. Extend StageAwareSprite instead of Sprite to get automatic handing of any stage-related activity. This simply saves you all the hassle of adding and removing the event listeners yourself. The class has protected addedToStage, removedFromStage and stageResize methods that are triggered [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s another handy little object. Again, it&#8217;s pretty trivial but might save you 10 minutes.</p>
<p>Extend <a href="/source/com/aderowbotham/utils/StageAwareSprite.as">StageAwareSprite</a> instead of Sprite to get automatic handing of any stage-related activity. This simply saves you all the hassle of adding and removing the event listeners yourself.</p>
<p>The class has protected <em>addedToStage</em>, <em>removedFromStage</em> and <em>stageResize</em> methods that are triggered as you expect but which do nothing by default. They are intended to be extended so you can create your own custom behaviours.</p>
<p>Files:<br />
<a href="/source/com/aderowbotham/utils/StageAwareSprite.as" title="StageAwareSprite ActionScript class">com.aderowbotham.utils.StageAwareSprite</a><br />
<a href="/source/StageSpriteDemo.zip" title="Demo ZIP">StageSpriteDemo.zip</a></p>
<p>Example usage &ndash; this could be the base class for a library object:</p>
<pre>
package {
	import com.aderowbotham.utils.StageAwareSprite;	

	public class Demo extends StageAwareSprite {

		public function Demo() {
			super();
		}

		override protected function addedToStage():void{
			trace("added to stage");
			trace("stageWidth = "+stageWidth,", stageHeight = "+stageHeight);
		}

		override protected function removedFromStage():void{
			trace("removed from stage");
		}

		override protected function stageResize():void{
			trace("stage resized to: "+stageWidth+", "+stageHeight);
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.aderowbotham.com/2010/01/stageawaresprite/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Leap year detection</title>
		<link>http://code.aderowbotham.com/2009/09/leap-year-detection/</link>
		<comments>http://code.aderowbotham.com/2009/09/leap-year-detection/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 15:53:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://code.aderowbotham.com/?p=45</guid>
		<description><![CDATA[A year will be a leap year if it is divisible by 4 but not by 100. If a year is divisible by 4 and by 100, it is not a leap year unless it is also divisible by 400. Translated into Actionscript 3.0, that looks like this: function getIsLeapyear(year:int):Boolean{ var result:Boolean = false; var [...]]]></description>
			<content:encoded><![CDATA[<p>A year will be a leap year if it is divisible by 4 but not by 100. If a year is divisible by 4 <em>and</em> by 100, it is not a leap year unless it is also divisible by 400.</p>
<p>Translated into Actionscript 3.0, that looks like this:</p>
<pre>function getIsLeapyear(year:int):Boolean{
	var result:Boolean = false;
	var divBy4:Boolean = (year % 4 == 0);
	var divBy100:Boolean = (year % 100 == 0);
	var divBy400:Boolean =  (year % 400 == 0);

	if(divBy4){
		if(divBy100){
			if(divBy400){
				result = true;
			} else {
				result = false;
			}
		} else {
			result = true;
		}
	} else {
		result = false;
	}
	return result;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.aderowbotham.com/2009/09/leap-year-detection/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Remove spaces</title>
		<link>http://code.aderowbotham.com/2009/09/remove-spaces/</link>
		<comments>http://code.aderowbotham.com/2009/09/remove-spaces/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 16:31:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[utils]]></category>

		<guid isPermaLink="false">http://code.aderowbotham.com/?p=34</guid>
		<description><![CDATA[Busy busy busy&#8230;. I&#8217;ve been too busy to blog for longer than I can remember. I&#8217;ve got loads of stuff to post, but it needs a bit of cleaning up first (as most of it suffered late night last-minute hacks to accommodate client changes). But anyway, here&#8217;s a simple little String function that removes any [...]]]></description>
			<content:encoded><![CDATA[<p>Busy busy busy&#8230;. I&#8217;ve been too busy to blog for longer than I can remember.</p>
<p>I&#8217;ve got loads of stuff to post, but it needs a bit of cleaning up first (as most of it suffered late night last-minute hacks to accommodate client changes).</p>
<p>But anyway, here&#8217;s a simple little String function that removes any spaces from the start or end of a String, and removes any multiple spaces from within a String.</p>
<p>For example:</p>
<pre>Input: "&nbsp;&nbsp;&nbsp;&nbsp; Hello&nbsp;&nbsp;&nbsp;world        "
Output: "Hello world" </pre>
<p>Here&#8217;s the code (Flash AS3):</p>
<pre>function removeSpaces(string:String):String{

	//remove spaces at start
	while(string.substr(0,1) == " "){
		string = string.substring(1);
	}
	//remove multiple spaces in middle
	while(string.indexOf("  ") != -1){
		string = string.split("  ").join(" ");
	}
	while(string.substr(-1) == " "){
		string = string.substr(0,string.length-1);
	}
	return string;
}</pre>
<p>Might save you five minutes!</p>
]]></content:encoded>
			<wfw:commentRss>http://code.aderowbotham.com/2009/09/remove-spaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sequence Randomiser</title>
		<link>http://code.aderowbotham.com/2009/02/sequence-randomiser/</link>
		<comments>http://code.aderowbotham.com/2009/02/sequence-randomiser/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 12:18:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[utils]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[randomisation]]></category>
		<category><![CDATA[randomise]]></category>
		<category><![CDATA[randomization]]></category>
		<category><![CDATA[randomize]]></category>
		<category><![CDATA[sequencer]]></category>
		<category><![CDATA[sequences]]></category>

		<guid isPermaLink="false">http://code.aderowbotham.com/?p=25</guid>
		<description><![CDATA[So I said I&#8217;d be back and here I am. I won&#8217;t bore you with specific excuses but I&#8217;ve honestly had a lot to do in the last few months. Here&#8217;s another simple utility that came out of something old. It simply returns an array of consecutive integers, only in a random order, with no [...]]]></description>
			<content:encoded><![CDATA[<p>So I said I&#8217;d be back and here I am. I won&#8217;t bore you with specific excuses but I&#8217;ve honestly had a lot to do in the last few months.</p>
<p>Here&#8217;s another simple utility that came out of something old. It simply returns an array of consecutive integers, only in a random order, with no reptition. By default the smallest value is zero and the highest is the length of array requested &#8211; 1. However you can set the base value via an optional second argument.</p>
<p>A typical usage would be to trigger a number of animations in a random order. </p>
<p>Again, simple stuff but if it saves you 10 minutes then this post was worthwhile.</p>
<p>Files:<br />
<a href="/source/com/aderowbotham/utils/SequenceRandomiser.as">com.aderowbotham.utils.SequenceRandomiser</a></p>
<p>Usage:</p>
<pre>
import com.aderowbotham.utils.SequenceRandomiser;

//create a sequence of length 10
var mySequence:Array = SequenceRandomiser.createSequence(10);
trace(mySequence);    //e.g. 5,0,7,8,2,4,1,9,6,3

//create a sequence of length 10, from -5
mySequence = SequenceRandomiser.createSequence(10,-5);
trace(mySequence);    //e.g. -4,-5,0,-3,2,1,3,-2,4,-1
</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.aderowbotham.com/2009/02/sequence-randomiser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CalcTools</title>
		<link>http://code.aderowbotham.com/2008/08/calctools/</link>
		<comments>http://code.aderowbotham.com/2008/08/calctools/#comments</comments>
		<pubDate>Mon, 11 Aug 2008 17:55:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://code.aderowbotham.com/?p=17</guid>
		<description><![CDATA[Here&#8217;s a calculator utility package which contains a few handy Mathematical shortcuts. A lot of it came out of some old game code, such as getIsInRange($p1,$p2,range) which returns true if position1 is within the specified range of position2. $p1 and $p2 are instances of PositionObject which contains coordinates. PositionObject supports 1, 2 or 3 dimensions, [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a calculator utility package which contains a few handy Mathematical shortcuts.</p>
<p>A lot of it came out of some old game code, such as <em>getIsInRange($p1,$p2,range)</em> which returns true if position1 is within the specified range of position2. $p1 and $p2 are instances of <em>PositionObject</em> which contains coordinates.</p>
<p><em>PositionObject</em> supports 1, 2 or 3 dimensions, but <em>getIsInRange</em> only works with 1 or 2-dimensional PositionObjects at the moment &#8211; i.e. z-distance is ignored. I&#8217;ll update the maths to work in 3D at some point!</p>
<p>Files:<br />
<a title="CalcTools.as" href="/source/com/aderowbotham/utils/calc/CalcTools.as">com.aderowbotham.utils.calc.CalcTools</a><br />
<a title="CalcReturnObject.as" href="/source/com/aderowbotham/utils/calc/CalcReturnObject.as">com.aderowbotham.utils.calc.CalcReturnObject</a><br />
<a title="PositionObject.as" href="/source/com/aderowbotham/utils/calc/PositionObject.as">com.aderowbotham.utils.calc.PositionObject</a></p>
<p>Example usage:</p>
<pre>import com.aderowbotham.utils.calc.CalcTools;
import com.aderowbotham.utils.calc.PositionObject;

var p1:PositionObject = new PositionObject(100,0);
var p2:PositionObject = new PositionObject(100,20);

trace("check range: "+CalcTools.getIsInRange(p1,p2,30));
//returns true because distance is 20 but the range tested was 30
</pre>
<p>There&#8217;s loads of other stuff in there too.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.aderowbotham.com/2008/08/calctools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Source</title>
		<link>http://code.aderowbotham.com/2008/08/source/</link>
		<comments>http://code.aderowbotham.com/2008/08/source/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 16:33:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[utils]]></category>

		<guid isPermaLink="false">http://code.aderowbotham.com/?p=12</guid>
		<description><![CDATA[To kick off (and I&#8217;ve not got anything else ready) I&#8217;ve posted some AS3 source code. At the moment, this just contains my utils directory and doesn&#8217;t really do much on its own. The rest will slot into this folder structure as and when it&#8217;s ready: code.aderowbotham.com/source You may find a few handy bits and [...]]]></description>
			<content:encoded><![CDATA[<p>To kick off (and I&#8217;ve not got anything else ready) I&#8217;ve posted <a title="Source Code" href="/source/">some AS3 source code</a>. At the moment, this just contains my <em>utils</em> directory and doesn&#8217;t really do much on its own. The rest will slot into this folder structure as and when it&#8217;s ready:</p>
<p><a title="Source Code" href="/source/">code.aderowbotham.com/source</a></p>
<p>You may find a few handy bits and pieces in there. There&#8217;s not much at present but I reuse these classes a lot.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.aderowbotham.com/2008/08/source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

