<?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>Programming Tutorials @ Rslegion.Net</title>
	<atom:link href="http://www.rslegion.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rslegion.net</link>
	<description>Programming Tutorials From Many Languages</description>
	<lastBuildDate>Mon, 07 Sep 2009 21:27:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Actionscript 3 Imports</title>
		<link>http://www.rslegion.net/uncategorized/actionscript-3-imports/</link>
		<comments>http://www.rslegion.net/uncategorized/actionscript-3-imports/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 21:27:07 +0000</pubDate>
		<dc:creator>Rslegion</dc:creator>
				<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://www.rslegion.net/?p=212</guid>
		<description><![CDATA[Just a short post today, alot of you have been asking me why you need to use import statements when you&#8217;re code seems to work with or without them anyway.
Here&#8217;s the answer:
Most of the time developers / Tut writers get you to put in the import as good practice for when you start using classes. [...]]]></description>
			<content:encoded><![CDATA[<p>Just a short post today, alot of you have been asking me why you need to use import statements when you&#8217;re code seems to work with or without them anyway.</p>
<p>Here&#8217;s the answer:</p>
<p>Most of the time developers / Tut writers get you to put in the import as good practice for when you start using classes. Everything used in a class has to be imported. This is usually to increase loading times and decrease file size.</p>
<p>Just for all you that wondered how to do an import, heres an example:</p>
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax1"></a><a style="wp-synhighlighter-title" href="#codesyntax1"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="actionscript3" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #000000; font-weight: bold;">*</span>;</div></li></ol></pre></div></div></p>
<p>This will import everything in the /flash/display folder of you&#8217;re classpath</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rslegion.net/uncategorized/actionscript-3-imports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Useful Functions (Tips)</title>
		<link>http://www.rslegion.net/actionscript-3/useful-functions-tips/</link>
		<comments>http://www.rslegion.net/actionscript-3/useful-functions-tips/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 08:00:30 +0000</pubDate>
		<dc:creator>Matthew Lodge</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://www.rslegion.net/?p=200</guid>
		<description><![CDATA[The following code generates an array then adds all the numbers in the array together. Really quite useless. 
However the methods used to create this snippet are extremely useful.
 Here I break them down.
]]></description>
			<content:encoded><![CDATA[<p>The following code generates an array then adds all the numbers in the array together. Really quite useless. </p>
<p>However the methods used to create this snippet are extremely useful.</p>
<p> Here I break them down.</p>
<p><code><div><div class="wp-synhighlighter-expanded"><a name="#codesyntax2"></a><a style="wp-synhighlighter-title" href="#codesyntax2"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> randomNumber<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> myArray<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Array</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Array</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> total<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> totalNumbers<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=int%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:int.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">int</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
totalNumbers = <span style="color: #000000; font-weight:bold;">10</span>;</pre></div></div>
First of all I declare some variables by doing this the variables can be used in and outside of functions. This is called variable scope
<code><div><div class="wp-synhighlighter-expanded"><a name="#codesyntax3"></a><a style="wp-synhighlighter-title" href="#codesyntax3"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> generateNumbers<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
 <span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">uint</span></a>; i<span style="color: #000000; font-weight: bold;">&lt;</span>totalNumbers; i<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span></pre></div></div>
Here I start a loop with a variable as the number to count to. This lets you modify the code easily
<code><div><div class="wp-synhighlighter-expanded"><a name="#codesyntax4"></a><a style="wp-synhighlighter-title" href="#codesyntax4"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="actionscript3" style="font-family:monospace;">randomNumber = <a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Math</span></a>.<span style="color: #004993;">ceil</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=math%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:math.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">Math</span></a>.<span style="color: #004993;">random</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">5</span><span style="color: #000000; font-weight: bold;">^</span>i<span style="color: #000000; font-weight: bold;">^</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>
Here is the code that generates the random numbers. Math.ceil() rounds the numbers up to an interger. Math.random() generates a random number with is then multiplied by 5 to the power of "i"
<code><div><div class="wp-synhighlighter-expanded"><a name="#codesyntax5"></a><a style="wp-synhighlighter-title" href="#codesyntax5"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="actionscript3" style="font-family:monospace;">myArray.<span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span>randomNumber<span style="color: #000000;">&#41;</span>;</pre></div></div>
The push() function in an array add the value in the argument as a new value in the array.
<code><div><div class="wp-synhighlighter-expanded"><a name="#codesyntax6"></a><a style="wp-synhighlighter-title" href="#codesyntax6"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000;">&#125;</span>
 <span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> il<span style="color: #000000; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">uint</span></a>; il<span style="color: #000000; font-weight: bold;">&lt;</span>totalNumbers; il<span style="color: #000000; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
 total <span style="color: #000000; font-weight: bold;">+</span>= myArray<span style="color: #000000;">&#91;</span>il<span style="color: #000000;">&#93;</span>;</pre></div></div>
Here the variable "il" counts up until it equals "totalNumbers" whilst it does that it cycles through the array and adds the values to the variable "total" using the operator +=
<code><div><div class="wp-synhighlighter-expanded"><a name="#codesyntax7"></a><a style="wp-synhighlighter-title" href="#codesyntax7"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
generateNumbers<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>
Calling the function
<code><div><div class="wp-synhighlighter-expanded"><a name="#codesyntax8"></a><a style="wp-synhighlighter-title" href="#codesyntax8"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>myArray<span style="color: #000000;">&#41;</span>;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>total<span style="color: #000000;">&#41;</span>;</pre></div></div>
Here I trace to the output panel in flash to check the function is working. It is useful for debugging to put trace() functions in to see where the code is failing

So as you can see AS3 has many useful functions to help cut the time spent coding. Use these and you're on your way to becoming an ace programmer.</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.rslegion.net/actionscript-3/useful-functions-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Custom Classes And Packages In AS3</title>
		<link>http://www.rslegion.net/actionscript-3/creating-custom-classes-and-packages-in-as3/</link>
		<comments>http://www.rslegion.net/actionscript-3/creating-custom-classes-and-packages-in-as3/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 20:29:27 +0000</pubDate>
		<dc:creator>Rslegion</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[classes]]></category>

		<guid isPermaLink="false">http://www.rslegion.net/?p=196</guid>
		<description><![CDATA[Custom classes are one of the new features in AS3 and they are very useful to competent Actionscript 3.0 coders.
The main idea of the custom class is just like that of a custom function. Both of which were designed to:

 Help organize code
 Rid of the need for repeating code
 Increase application performance

On a very [...]]]></description>
			<content:encoded><![CDATA[<p>Custom classes are one of the new features in AS3 and they are very useful to competent Actionscript 3.0 coders.</p>
<p>The main idea of the custom class is just like that of a custom function. Both of which were designed to:</p>
<ul>
<li> Help organize code</li>
<li> Rid of the need for repeating code</li>
<li> Increase application performance</li>
</ul>
<p>On a very basic level, both classes and functions both do this, however classes allow the user to be much more dynamic with there code.</p>
<p>An empty class looks like this:<br />
<div><div class="wp-synhighlighter-expanded"><a name="#codesyntax9"></a><a style="wp-synhighlighter-title" href="#codesyntax9"  onClick="javascript:wpContainer=this.parentNode.parentNode.getElementsByTagName('div')[1];	if(wpContainer.style.display=='none') {wpContainer.style.display=''; this.parentNode.className='wp-synhighlighter-expanded'} 	else {wpContainer.style.display='none'; this.parentNode.className='wp-synhighlighter-collapsed'}">Code</a></div><div class="wp-synhighlighter-inner"><pre class="actionscript3" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #9900cc; font-weight: bold;">package</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<a href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:movieclip.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">MovieClip</span></a>;</div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ExampleClass extends <a href="http://www.google.com/search?q=movieclip%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:movieclip.html&amp;filter=0&amp;num=100&amp;btnI=lucky"><span style="color: #004993;">MovieClip</span></a></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #000000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> NewClass<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #000000;">&#123;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">		<span style="color: #000000;">&#125;</span></div></li><li style="font-weight: normal; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">	<span style="color: #000000;">&#125;</span></div></li><li style="font-weight: bold; vertical-align:top;"><div style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #000000;">&#125;</span></div></li></ol></pre></div></div></p>
<p>The order of code for a class looks like this:</p>
<p>1.) Declare &#8216;package&#8217;<br />
2.) Imports (Everything needs to be imported in a package / class)<br />
3.) Declare class name + its parent type (&#8221;MovieClip, Sprite, EventListener)<br />
4.) Main function (Run on class initiation)</p>
<p>This is the basics of custom class syntax, in the next tutorial, i will explain the use of these classes and how the improve you&#8217;re coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rslegion.net/actionscript-3/creating-custom-classes-and-packages-in-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting Up The Box2D B2World Object</title>
		<link>http://www.rslegion.net/actionscript-3/setting-up-the-box2d-b2world-object/</link>
		<comments>http://www.rslegion.net/actionscript-3/setting-up-the-box2d-b2world-object/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 21:23:28 +0000</pubDate>
		<dc:creator>Rslegion</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Box2D]]></category>

		<guid isPermaLink="false">http://www.rslegion.net/?p=193</guid>
		<description><![CDATA[When coding Box2D the first thing that needs to be setup is the Box2D world, known as the b2World.
Inside the b2World object, we set the attributes for:

Size &#8211; How large we want our b2World to be.
Gravity &#8211; How strong we want our gravity to be.
Sleeping Object &#8211; Used to speed our app.

Here is an example [...]]]></description>
			<content:encoded><![CDATA[<p>When coding Box2D the first thing that needs to be setup is the Box2D world, known as the b2World.</p>
<p>Inside the b2World object, we set the attributes for:</p>
<ul>
<li>Size &#8211; How large we want our b2World to be.</li>
<li>Gravity &#8211; How strong we want our gravity to be.</li>
<li>Sleeping Object &#8211; Used to speed our app.</li>
</ul>
<p>Here is an example of how to set up a b2World:</p>
<div class="blogCode">
<p>public function setupWorld ():void<br />
{<br />
// Setup our universe size<br />
var universeSize:b2AABB = new b2AABB();<br />
universeSize.lowerBound.Set (-3000 / RATIO ,-3000 / RATIO);<br />
universeSize.upperBound.Set (3000 / RATIO ,3000 / RATIO);</p>
<p>// Setup our gravity<br />
var gravity:b2Vec2 = new b2Vec2(0 , 9.8);</p>
<p>// Setup sleeping<br />
var ignoreSleeping:Boolean = true;</p>
<p>// Create our world<br />
myWorld = new b2World(universeSize,gravity,ignoreSleeping)<br />
}
</p></div>
<p>Firstly we set our attributes for the size of our world, the universe size is set using a class called the b2AABB. It is basically a rectangle and the parameters UpperBound and LowerBound must be Set. In this example we our applying physics between -3000 px and 3000 px.</p>
<p>After that we must set up our gravity. The gravity is of a b2Vec2 class. The parameters required are X and Y. In this example, as all box2D lengths and in meters,the gravity has been set to 0 meters per second right and 9.8 meters per second down.</p>
<p>Next we have to create a variable to tell box2D whether to ignore sleeping objects. This is mainly just for performance. When an object is not moving, it is classed as sleeping. When an object is sleeping box2D can ignore it for performance increase. Usually, you&#8217;ll want this on.</p>
<p>Lastly we must actually create our world. This is of a b2World class and has the parameters:</p>
<ul>
<li>world:b2AABB</li>
<li>gravity:b2Vec2</li>
<li>doSleep:Boolean</li>
</ul>
<p>That sums up our tutorial on setting up the Box2D B2World object, in our next tutorial in this series we will look at how to create static objects in box2D</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rslegion.net/actionscript-3/setting-up-the-box2d-b2world-object/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Introduction To The Box2D Physics Engine</title>
		<link>http://www.rslegion.net/actionscript-3/an-introduction-to-the-box2d-physics-engine/</link>
		<comments>http://www.rslegion.net/actionscript-3/an-introduction-to-the-box2d-physics-engine/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 22:28:54 +0000</pubDate>
		<dc:creator>Rslegion</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Box2D]]></category>
		<category><![CDATA[Introduction]]></category>
		<category><![CDATA[Physics Engine]]></category>

		<guid isPermaLink="false">http://www.rslegion.net/?p=189</guid>
		<description><![CDATA[This is the first of a range of tutorials covering use of the open source Box2D physics engine. This engine the physics engine of choice of AS3 and has more than likely been used to create some of you&#8217;re favorite games like &#8216;Fantastic Contraption&#8217; and &#8216;Super Stacker&#8217;
I know what you&#8217;re thinking,
How am I going to [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first of a range of tutorials covering use of the open source Box2D physics engine. This engine the physics engine of choice of AS3 and has more than likely been used to create some of you&#8217;re favorite games like &#8216;Fantastic Contraption&#8217; and &#8216;Super Stacker&#8217;</p>
<p>I know what you&#8217;re thinking,</p>
<p><strong>How am I going to learn how to code all these gravity and physics things? </strong></p>
<p>The great part is, all the actual physics of the game have already been coded in the Box2D classes already. All we have to do is create the object, know as <em> bodies </em> in the Box2D world, and set there attributes!</p>
<p>In this tutorial i will cover the basics of Box2D and how it works.</p>
<p><strong>The Difference</strong></p>
<p>If you&#8217;re already an competent AS3 Coder, which you should be if you&#8217;re learning box2D, there are a few fundamental differences to the way things work.</p>
<p>In normal AS3 coding you have you&#8217;re sprites and MovieClips, they:</p>
<ul>
<li>Are Smart</li>
<li>Calculate where to move by themselves</li>
<li>Have an Event.Enter_Frame attached to them</li>
</ul>
<p>However sprites in Box2D are completey different, they:</p>
<ul>
<li>Aren&#8217;t so smart</li>
<li>Go where box2D <span style="text-decoration: underline;">tells them to go</span></li>
</ul>
<p>That&#8217;s the main difference when coding Box2D, its mainly because the engine is ported directly from the world of C++</p>
<p>In the next tutorial, i will cover how to set up Box2D so it knows where abouts on our flash movies that physics should be applied. Also know as the B2World.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rslegion.net/actionscript-3/an-introduction-to-the-box2d-physics-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mmmm&#8230;Cookies</title>
		<link>http://www.rslegion.net/php/mmmm-cookies/</link>
		<comments>http://www.rslegion.net/php/mmmm-cookies/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 08:00:10 +0000</pubDate>
		<dc:creator>Matthew Lodge</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.rslegion.net/?p=181</guid>
		<description><![CDATA[Time for a tutorial on PHP Cookies now. Every time you log into a site chances are you&#8217;re kept logged in with the help of cookies. Here I will show you a quick guide to cookies. 
Syntax and rules.

setcookie(name, value, expire, path, domain);

Cookies must be set before any information is displayed on the page. So [...]]]></description>
			<content:encoded><![CDATA[<p>Time for a tutorial on PHP Cookies now. Every time you log into a site chances are you&#8217;re kept logged in with the help of cookies. Here I will show you a quick guide to cookies. </p>
<h4>Syntax and rules.</h4>
<div class="blogCode">
setcookie(name, value, expire, path, domain);
</div>
<p>Cookies must be set before any information is displayed on the page. So set your cookies before the  tag and before you echo() or print() anything.</p>
<h4>Ok let&#8217;s do this&#8230;</h4>
<div class="blogCode">
$expire=time()+60*60*24*6;<br />
setcookie(&#8221;name&#8221;, &#8220;Matthew Lodge&#8221;, $expire);
</div>
<p>The first part of the code sets an expiry date for the cookie. Here it is set for a week from when the cookie is set. (60 seconds, 60 minutes, 24 hours and 6 days). This cookie is called name and will have a value of Matthew Lodge.</p>
<p>This code is fine for setting a cookie but it will reset the cookie every time the page is refreshed. so to keep the current cookie we can use an if statement.</p>
<div class="blogCode">
if(!isset($_COOKIE["name"])){<br />
$expire=time()+60*60*24*6;<br />
setcookie(&#8221;name&#8221;, &#8220;Matthew Lodge&#8221;, $expire);<br />
}
</div>
<p>This if statement checks whether the cookie exists and if it doesn&#8217;t it sets it.</p>
<p>Showing the value of a cookie is easy as shown below</p>
<div class="blogCode">
echo $_COOKIE["name"];<br />
//This will show the cookie that is called name</p>
<p>print_r &#8220;$_COOKIE&#8221;;<br />
//This will print all the cookies in an array
</p></div>
<p>To delete cookies you must set them in the past.</p>
<div class="blogCode">
setcookie(&#8221;name&#8221;, &#8221; &#8220;, time()-3600;<br />
//Sets the cookie an hour in the past and destroys it.
</div>
<p>So that&#8217;s cookies. Remember that some people do not have cookies enabled so always have a contingency plan if you want your application to be used by all.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rslegion.net/php/mmmm-cookies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Declaring Variables In Visual Basic.Net</title>
		<link>http://www.rslegion.net/visual-basic-net/declaring-variables-in-visual-basic-net/</link>
		<comments>http://www.rslegion.net/visual-basic-net/declaring-variables-in-visual-basic-net/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 22:54:00 +0000</pubDate>
		<dc:creator>Rslegion</dc:creator>
				<category><![CDATA[Visual Basic.Net]]></category>

		<guid isPermaLink="false">http://www.rslegion.net/?p=171</guid>
		<description><![CDATA[Variables in VB.Net are declared using this stereotypical programming format.
1.) The language must be told that you are declaring a variable.
2.) The name of the variable must be given.
3.) The variable type must be set.
In a language such as AS3 the code would look like this:

var myVar:String

In visual basic, as it is intended to be [...]]]></description>
			<content:encoded><![CDATA[<p>Variables in VB.Net are declared using this stereotypical programming format.</p>
<p>1.) The language must be told that you are declaring a variable.<br />
2.) The name of the variable must be given.<br />
3.) The variable type must be set.</p>
<p>In a language such as AS3 the code would look like this:</p>
<div class = "blogCode">
var myVar:String
</div>
<p>In visual basic, as it is intended to be a language for beginners, the code would look like this:</p>
<div class = "blogCode">
dim myVar as String
</div>
<p>In visual basic, the word <em> var </em> is unused and is replaced by <em> dim. </em> Why dim is used is have no idea.</p>
<p>However, you will notice that the colon in AS3 is replaced by <em> as </em>.</p>
<p>This is the beauty of learning Visual Basic.Net as a first programming language. If you know to replace the word dim with declare, and you know that a <em> string </em> is text. </p>
<p><strong> This line of code is written in Pure English. </strong></p>
<p><em> declare myVariable as text </em> </p>
<p>You don&#8217;t need to be an expert to understand this. Do ya&#8217;?</p>
<p>This is the case with a lot of VB.Net code and is a reason why a lot of people opt to learn this language before moving on to more complex languages such as PHP or C++</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rslegion.net/visual-basic-net/declaring-variables-in-visual-basic-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &amp; mySQL: An intro</title>
		<link>http://www.rslegion.net/php/php-mysql-an-intro/</link>
		<comments>http://www.rslegion.net/php/php-mysql-an-intro/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 16:57:00 +0000</pubDate>
		<dc:creator>Matthew Lodge</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.rslegion.net/?p=167</guid>
		<description><![CDATA[The main benefit of PHP is its compatibility with mySQL. In this tutorial you will learn the basics of PHP and mySQL.
&#60;?php
$connection = mysql_connect(&#8217;SEVER&#8217;, &#8216;USER&#8217;, &#8216;PASSWORD&#8217;);
$selectdb = mysql_select_db(&#8217;DB NAME&#8217;);
if(!$connection){
die(&#8217;Error connecting to database server&#8217;);
}
if(!$selectdb){
die(&#8217;Error connecting to selected database&#8217;);
}
//This code connects the page to the database ready to make a query. By holding //the connection functions in [...]]]></description>
			<content:encoded><![CDATA[<p>The main benefit of PHP is its compatibility with mySQL. In this tutorial you will learn the basics of PHP and mySQL.</p>
<div class="blogCode">&lt;?php</p>
<p>$connection = mysql_connect(&#8217;SEVER&#8217;, &#8216;USER&#8217;, &#8216;PASSWORD&#8217;);<br />
$selectdb = mysql_select_db(&#8217;DB NAME&#8217;);</p>
<p>if(!$connection){<br />
die(&#8217;Error connecting to database server&#8217;);<br />
}<br />
if(!$selectdb){<br />
die(&#8217;Error connecting to selected database&#8217;);<br />
}</p>
<p>//This code connects the page to the database ready to make a query. By holding //the connection functions in variables we can create a custom error message.</p>
<p>?&gt;</p></div>
<p>Next I will teach you about query syntax. A basic query follows this rule:</p>
<div class="blogCode">SELECT name FROM table</div>
<p>The SELECT tells mySQL to return a value from the specified field (in this example the field is called &#8220;name&#8221;). Alternatively you can use the * wild card. This requests all the information from the table selected in the FROM parameter.<br />
The FROM tells mySQL which table in the database the field can be found.</p>
<p>For example to retrieve a name from a table called users the code would look like this:</p>
<div class="blogCode">$query = mysql_query(&#8221;SELECT * FROM users&#8221;);<br />
if(!$query){<br />
die(&#8217;Error in query&#8217;);<br />
}</p>
<p>while($row = mysql_fetch_array($query)){<br />
echo $row['firstname'];<br />
echo &#8220;&lt;br /&gt;&#8221;;<br />
}</p></div>
<p>First of all we query the database for a set of results. Then we echo out all the results using a WHILE loop. The $row variable contains all the information so we specify what information we want from the query using ['']. This returns the information from that field.</p>
<p>The full code</p>
<div class="blogCode">&lt;?php$connection = mysql_connect(&#8217;SEVER&#8217;, &#8216;USER&#8217;, &#8216;PASSWORD&#8217;);<br />
$selectdb = mysql_select_db(&#8217;DB NAME&#8217;);</p>
<p>if(!$connection){<br />
die(&#8217;Error connecting to database server&#8217;);<br />
}<br />
if(!$selectdb){<br />
die(&#8217;Error connecting to selected database&#8217;);<br />
}</p>
<p>$query = mysql_query(&#8221;SELECT * FROM users&#8221;);<br />
if(!$query){<br />
die(&#8217;Error in query&#8217;);<br />
}</p>
<p>while($row = mysql_fetch_array($query)){<br />
echo $row['firstname'];<br />
echo &#8220;&lt;br /&gt;&#8221;; //Add a line break for formatting<br />
}</p>
<p>mysql_close($connection);</p>
<p>?&gt;</p></div>
<p>The mysql_close() function will close the connection to the database</p>
<p>So as you can see PHP and mySQL can be a formidable combination. By integrating them into your site you can give users an enhanced experience.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rslegion.net/php/php-mysql-an-intro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Introduction To Visual Basic.Net</title>
		<link>http://www.rslegion.net/visual-basic-net/an-introduction-to-visual-basic-net/</link>
		<comments>http://www.rslegion.net/visual-basic-net/an-introduction-to-visual-basic-net/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 22:17:28 +0000</pubDate>
		<dc:creator>Rslegion</dc:creator>
				<category><![CDATA[Visual Basic.Net]]></category>
		<category><![CDATA[Introduction]]></category>

		<guid isPermaLink="false">http://www.rslegion.net/?p=153</guid>
		<description><![CDATA[Visual Basic, in my opinion is an extremely easy programming language to learn. It where i first started many years ago. One of the the reasons that visual basic is easy to learn on a beginner level is because most of its commands are in the English language.
 For Example in Actionscript 3, you&#8217;ll see [...]]]></description>
			<content:encoded><![CDATA[<p>Visual Basic, in my opinion is an extremely easy programming language to learn. It where i first started many years ago. One of the the reasons that visual basic is easy to learn on a beginner level is because most of its commands are in the English language.</p>
<p> For Example in Actionscript 3, you&#8217;ll see code like this:</p>
<div class = "blogCode">
if(someCode == true)<br />
{<br />
someMoreCode = false<br />
}
</div>
<p>Whereas in Visual Basic.Net, the same code would look more like this:</p>
<div class = "blogCode">
If someCode = true Then someMoreCode = false
</div>
<p>As you can see, Visual basic code looks much more simple to the beginner than AS3. Even though both example do exactly the same thing.</p>
<p>This is the reason why i recommend learning Visual Basic.Net as you&#8217;re first programming language.</p>
<p>Check back regularly for more Visual Basic.Net tutorials. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rslegion.net/visual-basic-net/an-introduction-to-visual-basic-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating A Simple Preloader In As3</title>
		<link>http://www.rslegion.net/actionscript-3/creating-a-simple-preloader-in-as3/</link>
		<comments>http://www.rslegion.net/actionscript-3/creating-a-simple-preloader-in-as3/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 22:47:28 +0000</pubDate>
		<dc:creator>Rslegion</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://www.rslegion.net/?p=139</guid>
		<description><![CDATA[For all you that have been follow this blog from the start, you&#8217;re probably up to the point where you can create games and applications. For the large of these loading times can be a problem. After all, the chances of someone sitting there looking at a black screen for a minute while you&#8217;re game [...]]]></description>
			<content:encoded><![CDATA[<p>For all you that have been follow this blog from the start, you&#8217;re probably up to the point where you can create games and applications. For the large of these loading times can be a problem. After all, the chances of someone sitting there looking at a black screen for a minute while you&#8217;re game loads is unlikely.</p>
<p>This is where a preloader comes in, for everyone that doesn&#8217;t know, a preloader is a small piece of code that executes almost instantly and tells you how long until the rest of the game or app is loaded.</p>
<p>In this tutorial, i will show how to make one.</p>
<p><strong>Step 1</strong><br />
Create a dynamic text field. Give it an instance name of <em>percentComplete</em></p>
<p><strong>Step 2</strong><br />
In code view, add these 2 lines:</p>
<div class = "blogCode">
stop();<br />
this.stop();
</div>
<p>These will the our app from continuing while loading commences.</p>
<p><strong>Step 3</strong><br />
Add an event listener that is triggered each time part of our app loads and one for loading completion:</p>
<div class = "blogCode">
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, updatePercent);<br />
this.loaderInfo.addEventListener(Event.COMPLETE, loadComplete)
</div>
<p><strong>Step 4</strong><br />
Create our function and work out the percentage complete:</p>
<div class = "blogCode">
function updatePercent (e:ProgressEvent)<br />
var percent:Number = (e.bytesLoaded / e.bytesTotal) * 100;
</div>
<p>To work out the percentage complete will take the amount of app we have loaded and divide it but the total size of the app. Then times by 100.</p>
<p><strong>Step 5</strong><br />
Add in a line to set the text of the textfield underneath the previous:</p>
<div class = "blogCode">
percentComplete.text = (percent + &#8220;%&#8221;)
</div>
<p><strong>Step 6</strong><br />
Create a  function to handle the loading completion and move to the next frame.</p>
<div class = "blogCode">
function loadComplete (e:Event)<br />
{<br />
this.removeEventListener(ProgressEvent.PROGRESS, updatePercent)<br />
gotoAndStop(2)<br />
}
</div>
<p>And there you have it, a simple preloader in AS3</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rslegion.net/actionscript-3/creating-a-simple-preloader-in-as3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
