﻿<?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>Keith Hair</title>
	<atom:link href="http://keith-hair.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://keith-hair.net/blog</link>
	<description>Scripting is fun like any other hobby</description>
	<lastBuildDate>Thu, 18 Feb 2010 04:56:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>KeyManager Class for Detecting Key Press Combos or Sequences</title>
		<link>http://keith-hair.net/blog/2010/02/15/keymanager-class-for-detecting-key-press-combos-or-sequences/</link>
		<comments>http://keith-hair.net/blog/2010/02/15/keymanager-class-for-detecting-key-press-combos-or-sequences/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 23:30:12 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[ASWD]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[dev mode]]></category>
		<category><![CDATA[easter eggs]]></category>
		<category><![CDATA[key press]]></category>
		<category><![CDATA[Keyboard]]></category>
		<category><![CDATA[KeyboardEvent]]></category>
		<category><![CDATA[videogames]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=189</guid>
		<description><![CDATA[When I am writing a flash app or game which uses the keyboard to control a character's movement, there is a situation that becomes annoying while controlling the character. I do not know the proper term for it ("sticky keys"?) but I will describe it...
When an app or game is written we "expect" the user [...]]]></description>
			<content:encoded><![CDATA[<p>When I am writing a flash app or game which uses the keyboard to control a character's movement, there is a situation that becomes annoying while controlling the character. I do not know the proper term for it ("sticky keys"?) but I will describe it...<img class="alignright" src="/blog/examples/keycontrol/typing.jpg" alt="keyboard" width="264" height="386" /></p>
<p>When an app or game is written we "expect" the user to precisely press the proper key or key combination at a time to execute programmatic actions. However, most of us have ten fingers and we use more than one finger to press more than one button on the keyboard. The expected program reaction from multiple fingered keyboard input might not occur because you have another function executing when you expect just one at a time.<br />
<span id="more-189"></span></p>
<p><strong>Key Combinations</strong><br />
Imagine you are using the keyboard to play a game. The RIGHT arrow key is for moving your character right, the LEFT arrow key is for moving your character LEFT.<br />
Ok, the action in this game is heating up, you are pressing LEFT to avoid the lasers shooting at you. You successfully dodged the lasers, now you press RIGHT to move in and attack...but in the heat of battle, your other finger is still on the LEFT button. What happens now is your character most likely gets stuck, because both movement keys are pressed telling the character to go in opposite directions!</p>
<p>In some cases allowing multiple key presses is how you want the app to react. For example you want the user to press both UP and RIGHT keys to move the characters in a diagonal direction. When to allow this and when not can be different among all of the control buttons. It becomes messy having to write "If" and "switch" statements to make the KeyboardEvent listeners work according to the different controls needed.</p>
<p><strong>Key Sequences</strong><br />
If you love video games cheats or the easter eggs developers sometimes place in apps you'll remember to access them, you will usually enter in a sequence of key presses. If you entered the sequence successfully you would have access to cool game cheats or some special developer mode of an application.</p>
<p><strong>KeyManager</strong><br />
For the above reasons I've written a KeyManager class to add key control that allows individual keys/keycombos the option to cancel out the any previous key/keycombo that are pressed down...and when key/keycombos are released, whatever key/keycombo that are still pressed will be active again. And for detecting key press sequences the KeyManager class will allow also.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_keycontrol_52041291"
			class="flashmovie"
			width="550"
			height="400">
	<param name="movie" value="http://keith-hair.net/blog/examples/keycontrol/keycontrol.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://keith-hair.net/blog/examples/keycontrol/keycontrol.swf"
			name="fm_keycontrol_52041291"
			width="550"
			height="400">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>This is a basic example using KeyManager. The "addKey" method is for adding key press combos and the "addKeySequence" is for obviously adding<br />
key press sequences.</p>
<p>In the working flash example, you can click "singular combos" checkbox to false, to see the problem described previously about the character getting stuck when pressing RIGHT and LEFT key at the same time. When you set the checkbox back to true you will notice how each new key press overrides any others that are still down. This results in responsive execution if a user has a habit of holding down other keys while pressing new ones..</p>
<p><em><strong>Also in the working sample above if you enter in the proper key sequence you will be rewarded with an "Easter Egg" to view the source and FLA.</strong></em></p>
<p><strong>Example usage:</strong></p>
<pre class="brush: as3;">
import net.keithhair.KeyManager;

var keyManager:KeyManager;
keyManager=new KeyManager(stage);
keyManager.addKey([&quot;right&quot;], goRight,stopRight,&quot;control1&quot;);
keyManager.addKey([&quot;left&quot;], goLeft,stopLeft,&quot;control2&quot;);
keyManager.addKey([&quot;up&quot;], goUp,stopUp,&quot;control3&quot;);
keyManager.addKey([&quot;down&quot;], goDown,stopDown,&quot;control4&quot;);
keyManager.addKey([&quot;shift&quot;,&quot;w&quot;,&quot;t&quot;], toggleWindow);
keyManager.addKeySequence([&quot;up&quot;,&quot;up&quot;,&quot;down&quot;,&quot;down&quot;,&quot;left&quot;,&quot;right&quot;,&quot;left&quot;,&quot;right&quot;],openEasterEgg);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2010/02/15/keymanager-class-for-detecting-key-press-combos-or-sequences/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Different signs of Cosine, Sine, and Tangent functions and radians</title>
		<link>http://keith-hair.net/blog/2010/01/24/different-signs-of-cosine-sine-and-tangent-functions-and-radians/</link>
		<comments>http://keith-hair.net/blog/2010/01/24/different-signs-of-cosine-sine-and-tangent-functions-and-radians/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 18:27:43 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[cartesian]]></category>
		<category><![CDATA[coordinates]]></category>
		<category><![CDATA[Cosine]]></category>
		<category><![CDATA[quadrants]]></category>
		<category><![CDATA[Sine]]></category>
		<category><![CDATA[Tangent]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=176</guid>
		<description><![CDATA[
This post might seem of little importance to some but today I was thinking back to my high school days and (vaguely) remember the 4 quadrants of a Cartesian coordinate plane discussed in class. Depending on the positive or negative sign of a Point's X and Y value, that point in the Cartesian coordinate plane [...]]]></description>
			<content:encoded><![CDATA[<p>
This post might seem of little importance to some but today I was thinking back to my high school days and (vaguely) remember the 4 quadrants of a Cartesian coordinate plane discussed in class. Depending on the positive or negative sign of a Point's X and Y value, that point in the Cartesian coordinate plane will be located in one of these 4 quadrants.</p>
<blockquote><p><strong>Quadrant 1 = (+,+)<br />
Quadrant 2 = (-,+)<br />
Quadrant 3 = (-,-)<br />
Quadrant 4 = (-,+)</strong></p></blockquote>
<p>My interest in this post is about the positive or negative sign of what the Cosine, Sine, and Tangent functions return for the same angle...the angle from one Point to another Point. The sign of these 3 Math functions are different also whenever a Point is located in one of the 4 quadrants.</p>
<blockquote><p><strong>Quadrant 1 = +Sine,+Cosine,+Tangent<br />
Quadrant 2 = +Sine,-Cosine,-Tangent<br />
Quadrant 3 = -Sine,-Cosine,+Tangent<br />
Quadrant 4 = -Sine,+Cosine,-Tangent</strong></p></blockquote>
<p>Personally I don't think the order or name of the quadrants are important, as long as you keep them consistent with the coordinate system. For my usage, I order my quadrants "1,2,3,4" clockwise since ActionScript's radians values go clockwise.</p>
<p>I feel this will become useful sometime in the future for me when dealing with angles of Points and determining their positions relative to each other.<br />
In a future situation I might not be given X and Y information, but may only have angle data instead. Seeing the difference of signs from the Cosign, Sine, Tangent output of the angle value will be helpful clues.</p>
<p>So some things come back to haunt you, if they are the ghosts of my math teachers, I will surely pay attention in class this time <img src='http://keith-hair.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_quadrants_1563347973"
			class="flashmovie"
			width="550"
			height="400">
	<param name="movie" value="/blog/examples/different_signs/quadrants.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/blog/examples/different_signs/quadrants.swf"
			name="fm_quadrants_1563347973"
			width="550"
			height="400">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
<span id="more-176"></span><br />
Note in Flash/Actionscript, (0,0) is wherever you set your registration point of a MovieClip. In this example I centered the registration point in Flash,<br />
so (0,0) of head's coordinate system will sit directly at the center of the head.</p>
<pre class="brush: as3;">
	/*=========================================================
	Using &quot;Math.atan2&quot; to get the angle (in radians) between
	the &quot;reddot&quot; and &quot;head&quot;.

	This radian is fed into the &quot;getSign&quot; function so
	we can see the difference of signs.
	===========================================================*/

	var radians=Math.atan2(reddot.y-head.y,reddot.x-head.x);
	var signs:Object=getSigns(radians);
	var output:String=&quot;&quot;;

	output+=&quot;Sine:&quot;+signs.sine;
	output+=&quot;\n&quot;;
	output+=&quot;Cosine:&quot;+signs.cosine;
	output+=&quot;\n&quot;;
	output+=&quot;Tangent:&quot;+signs.tangent;
	output+=&quot;\n&quot;;
	output+=&quot;\n&quot;;
	output+=&quot;Radians:&quot;+radians;

	status.text=output;
</pre>
<pre class="brush: as3;">
/*============================================
Returns an object indicating the sign
of the radian's Cosine, Sine and Tangent.
==============================================*/
function getSigns(rad:Number):Object
{
	var o:Object=new Object();
	if(Math.sin(rad) &gt;= 0){
		o.sine=&quot;+&quot;;
	}else{
		o.sine=&quot;-&quot;;
	}
	if(Math.cos(rad) &gt;= 0){
		o.cosine=&quot;+&quot;;
	}else{
		o.cosine=&quot;-&quot;;
	}
	if(Math.tan(rad) &gt;= 0){
		o.tangent=&quot;+&quot;;
	}else{
		o.tangent=&quot;-&quot;;
	}
	return o;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2010/01/24/different-signs-of-cosine-sine-and-tangent-functions-and-radians/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Happy New Year!</title>
		<link>http://keith-hair.net/blog/2009/12/31/happy-new-year/</link>
		<comments>http://keith-hair.net/blog/2009/12/31/happy-new-year/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 23:45:10 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[Happy]]></category>
		<category><![CDATA[New]]></category>
		<category><![CDATA[Year]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=164</guid>
		<description><![CDATA[Since you are visiting, I will take this chance to say Happy New Year to you.
I am writing this on the event horizon of a new year. 2009 taught me that each day is a gift and we are not promised a tomorrow. Yes, this sounds so cliché but it is something a lot of [...]]]></description>
			<content:encoded><![CDATA[<p>Since you are visiting, I will take this chance to say Happy New Year to you.<br />
I am writing this on the event horizon of a new year. 2009 taught me that each day is a gift and we are not promised a tomorrow. Yes, this sounds so cliché but it is something a lot of us can relate to. That's pretty much all I have to say right now, so have a safe happy time...and a awesome HAPPY NEW YEAR!</p>
<p>-- Keith H -- </p>
]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2009/12/31/happy-new-year/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Everyone gets a turn</title>
		<link>http://keith-hair.net/blog/2009/12/11/everyone-gets-a-turn/</link>
		<comments>http://keith-hair.net/blog/2009/12/11/everyone-gets-a-turn/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 07:14:18 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[Components]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[dial]]></category>
		<category><![CDATA[knob]]></category>
		<category><![CDATA[NiceKnob]]></category>
		<category><![CDATA[spin]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=143</guid>
		<description><![CDATA[If everyone got a turn, would you take your turn the same as the others or be different?
I've seen lots of really great knobs, dials, and gauge components. The intended way a person would build their app to use one would most likely be varied . That makes each of these kinds of controls  special [...]]]></description>
			<content:encoded><![CDATA[<p>If everyone got a turn, would you take your turn the same as the others or be different?</p>
<p>I've seen lots of really great knobs, dials, and gauge components. The intended way a person would build their app to use one would most likely be varied . That makes each of these kinds of controls  special because its difficult to make a control that fits a very broad range of functionality/look-n-feel, and probably why I have yet to see "one knob to rule them all".   Sliders, and Buttons are pretty straight forward, but not the "Knob" type of control.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_DemoKnob_531673950"
			class="flashmovie"
			width="210"
			height="210">
	<param name="movie" value="http://keith-hair.net/blog/examples/niceknobs2/DemoKnob.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://keith-hair.net/blog/examples/niceknobs2/DemoKnob.swf"
			name="fm_DemoKnob_531673950"
			width="210"
			height="210">
	<!--<![endif]-->
		
<p style="text-align: center;"><a href="http://adobe.com/go/getflashplayer"><img class="aligncenter" src="http://keith-hair.net/blog/examples/niceknobs2/niceknobs2.jpg" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p style="text-align: left;"><span id="more-143"></span></p>
<p style="text-align: left;">Knobs can be just like a glass of tea. Some like a twist of lemon in it, or twist of lime etc. Just like others who have made their own controls tailor made to their needs, I have done with my knob.  The good thing about that is there's always more than one person who share the same preference on how a knob should function.  I've made many custom knobs that were built for small and simple duties. I'd like to make a knob to share here that is more reusable and cover wider ranges of functionality than the older ones I've built.  The knob displayed here is configurable but not skinnable, I've chosen to draw my knob dynamically with ActionScript's drawing API.  I hope to release this one after fixing some problems in my spare time.</p>
<p style="text-align: left;"><a title="NiceKnobs Revisited" href="http://keith-hair.net/blog/examples/niceknobs2/index.html" target="_blank">View demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2009/12/11/everyone-gets-a-turn/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Listing class properties dynamically in AS3</title>
		<link>http://keith-hair.net/blog/2009/12/08/listing-class-properties-dynamically-in-as3/</link>
		<comments>http://keith-hair.net/blog/2009/12/08/listing-class-properties-dynamically-in-as3/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 01:23:01 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[describeType]]></category>
		<category><![CDATA[ObjectUtil.getClassInfo]]></category>
		<category><![CDATA[RegExp]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=119</guid>
		<description><![CDATA[Dynamically listing the properties of a class is pretty cool and useful. There are many things you could do by generating a list of existing properties. One example is you can make your class instances represent themselves dynamically in a custom format of your choosing. Like how "toString()" is use with the Array class or [...]]]></description>
			<content:encoded><![CDATA[<p>Dynamically listing the properties of a class is pretty cool and useful. There are many things you could do by generating a list of existing properties. One example is you can make your class instances represent themselves dynamically in a custom format of your choosing. Like how "toString()" is use with the Array class or how Point is represented when toString() is called from it. Going further, listing current properties could be used to save the current values of the class as a "save point". </p>
<p>In the Flex framework, there is ObjectUtil.getClassInfo().properties, but I feel is more useful to just use the XML returned from the describeType method. I like using decribeType for both plain AS3 or when using the Flex framework because its accessible in both.<br />
Since the return of describeType is XML I have more options with E4X filtering/Regular Expressions, than using getClassInfo(). With describeType I can get info on methods as well but to keep things simple I'm only talking about accessor properties in this post. Using the "listProperties" function, I am listing the properties between 3 different classes. This is a function I wrote to show how you can make your own way to use the XML of decribeType. </p>
<p>In the example SWF below, there are 3 classes under inspection. The Helicopter class is a custom class extending Sprite. By setting the parameters of listProperties you can list the properties of Helicopter, or all of the properties it has by being subclassed from Sprite. The other classes are a TextField and a Sprite class. Changing the options lists a different set of properties based on type of Class of properties listed and what class its properties are declared by.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_readprops_1292606428"
			class="flashmovie"
			width="500"
			height="400">
	<param name="movie" value="http://keith-hair.net/blog/examples/listing_properties/readprops.swf" />
	<param name="scale" value="showall" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://keith-hair.net/blog/examples/listing_properties/readprops.swf"
			name="fm_readprops_1292606428"
			width="500"
			height="400">
		<param name="scale" value="showall" />
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
<span id="more-119"></span><br />
<br></br><br />
<strong>The custom Helicopter class extending Sprite</strong></p>
<pre class="actionscript">&nbsp;
package
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Helicopter <span style="color: #0066CC;">extends</span> Sprite
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _roll:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _pitch:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _yaw:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>;
&nbsp;
		<span style="color: #000000; font-weight: bold;">function</span> Helicopter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> roll<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> _roll;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> roll<span style="color: #66cc66;">&#40;</span>v:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_roll=v;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> pitch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> _pitch;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> pitch<span style="color: #66cc66;">&#40;</span>v:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_pitch=v;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> yaw<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">return</span> _yaw;
		<span style="color: #66cc66;">&#125;</span>
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> yaw<span style="color: #66cc66;">&#40;</span>v:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			_yaw=v;
&nbsp;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<pre class="actionscript">&nbsp;
<span style="color: #808080; font-style: italic;">/*============================================================
  obj						-The instance to return properties of.
  accessType				-Set to either &quot;readwrite&quot; or &quot;readonly&quot; to return only those kind of properties.
  excludeCommonWith			-Excludes all properties 'obj' has in common with the Class you give here.
  matchesRE					-If set listProperties will only return the property names that match the RegExp.
  declaredOnlyByObjClass	-If false, will not exclude properties declared by other classes than the givin 'obj'.  
&nbsp;
  Returns and Array of all the properties of the instance.
 ============================================================*/</span>
<span style="color: #000000; font-weight: bold;">function</span> listProperties<span style="color: #66cc66;">&#40;</span>obj:<span style="color: #0066CC;">Object</span>, accessType:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;readwrite&quot;</span>, excludeCommonWith:<span style="color: #000000; font-weight: bold;">Class</span>=<span style="color: #000000; font-weight: bold;">null</span>, matchesRE:RegExp=<span style="color: #000000; font-weight: bold;">null</span>, declaredOnlyByObjClass:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> a:XMLList;
	<span style="color: #000000; font-weight: bold;">var</span> b:<span style="color: #0066CC;">Array</span>=<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> c:*;
	<span style="color: #000000; font-weight: bold;">var</span> n:<span style="color: #0066CC;">int</span>;
	<span style="color: #000000; font-weight: bold;">var</span> doc:<span style="color: #0066CC;">XML</span>;
	<span style="color: #000000; font-weight: bold;">var</span> cname:<span style="color: #0066CC;">String</span>;
	matchesRE=matchesRE || <span style="color: #000000; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;.+&quot;</span><span style="color: #66cc66;">&#41;</span>;
	accessType=accessType || <span style="color: #ff0000;">&quot;readwrite&quot;</span>;
	accessType=accessType.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!RegExp<span style="color: #66cc66;">&#40;</span>/readwrite|readonly/i<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">test</span><span style="color: #66cc66;">&#40;</span>accessType<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		accessType == <span style="color: #ff0000;">&quot;readwrite&quot;</span>;
	<span style="color: #66cc66;">&#125;</span>
	doc=flash.<span style="color: #006600;">utils</span>.<span style="color: #006600;">describeType</span><span style="color: #66cc66;">&#40;</span>obj<span style="color: #66cc66;">&#41;</span>;
	cname=doc.@<span style="color: #0066CC;">name</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>declaredOnlyByObjClass<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		a=doc.<span style="color: #006600;">accessor</span>.<span style="color: #006600;"><span style="color: #66cc66;">&#40;</span></span>@access == accessType &amp;&amp; @declaredBy == cname &amp;&amp; matchesRE<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;test&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#40;</span>@<span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
		a=doc.<span style="color: #006600;">accessor</span>.<span style="color: #006600;"><span style="color: #66cc66;">&#40;</span></span>@access == accessType &amp;&amp; matchesRE<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;test&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#40;</span>@<span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>excludeCommonWith != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		c=<span style="color: #000000; font-weight: bold;">new</span> excludeCommonWith<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
	n=<span style="color: #cc66cc;">0</span>;
	<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>n &lt; a.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>c != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span>c<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">hasOwnProperty</span><span style="color: #66cc66;">&#40;</span>a<span style="color: #66cc66;">&#91;</span>n<span style="color: #66cc66;">&#93;</span>.@<span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				b.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>a<span style="color: #66cc66;">&#91;</span>n<span style="color: #66cc66;">&#93;</span>.@<span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
			b.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span>a<span style="color: #66cc66;">&#91;</span>n<span style="color: #66cc66;">&#93;</span>.@<span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
		n++;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">return</span> b;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p><a href="http://keith-hair.net/blog/examples/listing_properties/example.zip"><br />
download fla</a></p>
]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2009/12/08/listing-class-properties-dynamically-in-as3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>I&#8217;m Testing Foam physics in Flex</title>
		<link>http://keith-hair.net/blog/2009/08/01/im-testing-foam-physics-in-flex/</link>
		<comments>http://keith-hair.net/blog/2009/08/01/im-testing-foam-physics-in-flex/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 05:49:35 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[Foam]]></category>
		<category><![CDATA[Physics Engine]]></category>
		<category><![CDATA[Polygons]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=105</guid>
		<description><![CDATA[There are a lot of Flash physics engines available to use. I've only tried Box2D, APE, and Foam.
Foam is my favorite so far. I actually like the options of Box2D better but it's just not as ActionScript-friendly as Foam. 
Foam sets up the easiest of these 3 engines for an ActionScript only project...In my opinion, [...]]]></description>
			<content:encoded><![CDATA[<p>There are a lot of Flash physics engines available to use. I've only tried Box2D, APE, and Foam.<br />
<a href="http://drawlogic.com/2007/11/07/as3-foam-2d-physics-engine/">Foam </a>is my favorite so far. I actually like the options of Box2D better but it's just not as ActionScript-friendly as Foam. </p>
<p>Foam sets up the easiest of these 3 engines for an ActionScript only project...In my opinion, setting it up to use in my Flex projects takes a little more work depending on what I use it for. Seeing the end result of it is fun to watch.</p>
<p>Below I'm currently using my <a href="/blog/examples/polygon_physics/">polygon editor</a> to test Foam out in Flex.</p>
<p><a href="http://keith-hair.net/blog/examples/polygon_physics/"><img src="/blog/examples/polygon_physics/physics_polygons.jpg" alt="Click to view example" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2009/08/01/im-testing-foam-physics-in-flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Do you make tools to solve your problems?</title>
		<link>http://keith-hair.net/blog/2009/07/18/do-you-make-tools-to-solve-your-problems/</link>
		<comments>http://keith-hair.net/blog/2009/07/18/do-you-make-tools-to-solve-your-problems/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 07:06:17 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[interface]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=89</guid>
		<description><![CDATA[Does anyone out there throw together rough tools to solve eccentric problems that drive you nuts?
I run into problems with point data occasionally and it's hard to find a solution for using the data, when I can only view the problem in messy code format.
This sometimes leaves me wondering if the function I'm writing is [...]]]></description>
			<content:encoded><![CDATA[<p>Does anyone out there throw together rough tools to solve eccentric problems that drive you nuts?</p>
<p>I run into problems with point data occasionally and it's hard to find a solution for using the data, when I can only view the problem in messy code format.<br />
This sometimes leaves me wondering if the function I'm writing is even working correctly or not.<br />
&nbsp;<br />
The example below is a rough tool I made to visualize and edit the Array format of points I usually work with. Over time I have transformed, gutted, and replace its code for different tests I needed it for. (The insides are not pretty.)<br />
Yep it looks like a drawing tool, just not intended for that. I've only added certain "drawing" features I needed to make it easy to visualize the data I'm working on.</p>
<p><a href="http://keith-hair.net/blog/examples/pointtool/"><img src="/blog/examples/pointtool/pointtool.jpg" alt="Click to see example" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2009/07/18/do-you-make-tools-to-solve-your-problems/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Follow Freeman!</title>
		<link>http://keith-hair.net/blog/2009/06/08/follow-freeman/</link>
		<comments>http://keith-hair.net/blog/2009/06/08/follow-freeman/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 23:51:21 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Episode 3]]></category>
		<category><![CDATA[Gordon Freeman]]></category>
		<category><![CDATA[Half Life 2]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=80</guid>
		<description><![CDATA[I played some Half-Life 2 today, there's a lot of creativity that went into this game. As I played it again today it gave me a few laughs.
If you played the first installment of Half-Life 2, you may remember the NPC characters frequently shouting "Follow Freeman".
As the NPC characters stood around idle, they would make [...]]]></description>
			<content:encoded><![CDATA[<p>I played some Half-Life 2 today, there's a lot of creativity that went into this game. As I played it again today it gave me a few laughs.</p>
<p>If you played the first installment of Half-Life 2, you may remember the NPC characters frequently shouting "Follow Freeman".<br />
As the NPC characters stood around idle, they would make comments that sound as if they where on Twitter. LOL</p>
<p><img src="http://keith-hair.net/images/follow_freeman.jpg" alt="Follow Freeman!" /></p>
</p>
<p>Way back when the original Half-Life game came out and I played it on my ancient 3Dfx Voodoo card, the graphics blew me away. I've been loving the whole Half Life series and wait in anticipation for the next episode.<br />
I was disappointed that there was not much news of Half-Life 2 Episode 3 this year, so lately I been going back into time to enjoy the beginning of Half Life 2. I thought Half-Life 1 set the bar.<br />
This game set the bar again, the experience is so well done, that the replay value is good even for single player mode. I have lots PC games, once I finish one, I uninstall it. This is one of the few games I have worthy of staying installed for years.</p>
]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2009/06/08/follow-freeman/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Know where a Point is relevant to a Segment</title>
		<link>http://keith-hair.net/blog/2009/05/28/know-where-a-point-is-relevant-to-a-segment/</link>
		<comments>http://keith-hair.net/blog/2009/05/28/know-where-a-point-is-relevant-to-a-segment/#comments</comments>
		<pubDate>Thu, 28 May 2009 07:35:45 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Intersection]]></category>
		<category><![CDATA[Layout]]></category>
		<category><![CDATA[Placement]]></category>
		<category><![CDATA[Point]]></category>
		<category><![CDATA[Relavant]]></category>
		<category><![CDATA[Segment]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=68</guid>
		<description><![CDATA[Looking at my previous post I felt the isBehindLine function served it's purpose, but if I get a more complicated problem similar to a raycasting test with imaginary ray of arbitrary width I would need to know more information where a Point is relevant to a Segment. 
The "whereAboutSegment" function will return a String this [...]]]></description>
			<content:encoded><![CDATA[<p>Looking at my previous post I felt the <a href="http://keith-hair.net/blog/2009/05/27/knowing-if-a-point-is-behind-a-line">isBehindLine </a>function served it's purpose, but if I get a more complicated problem similar to a raycasting test with imaginary ray of arbitrary width I would need to know more information where a Point is relevant to a Segment. </p>
<p>The "whereAboutSegment" function will return a String this time, with more detailed info of the Point's where-a-abouts instead of just knowing if its behind a line.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_where_about_segment_632288709"
			class="flashmovie"
			width="550"
			height="400">
	<param name="movie" value="/blog/examples/intersections/where_about_segment.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/blog/examples/intersections/where_about_segment.swf"
			name="fm_where_about_segment_632288709"
			width="550"
			height="400">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><span id="more-68"></span></p>
<pre class="actionscript">&nbsp;
<span style="color: #808080; font-style: italic;">/*-----------------------------------------------------------------
Returns a String describing where Point P is relevant to line CD:
&quot;left&quot;,&quot;right&quot;,&quot;front&quot; or &quot;behind&quot;
If Point P is a Point on line CD, an empty String is returned.
 ----------------------------------------------------------------*/</span>
<span style="color: #000000; font-weight: bold;">function</span> whereAboutSegment<span style="color: #66cc66;">&#40;</span>P:Point,C:Point,D:Point<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> F:Point;
	<span style="color: #000000; font-weight: bold;">var</span> G:Point;
	<span style="color: #000000; font-weight: bold;">var</span> s:<span style="color: #0066CC;">Boolean</span>;
	<span style="color: #000000; font-weight: bold;">var</span> l:<span style="color: #0066CC;">Boolean</span>;
	<span style="color: #000000; font-weight: bold;">var</span> r:<span style="color: #0066CC;">Boolean</span>;
	<span style="color: #000000; font-weight: bold;">var</span> f:<span style="color: #0066CC;">Boolean</span>;
	<span style="color: #000000; font-weight: bold;">var</span> a:<span style="color: #0066CC;">Number</span>=Point.<span style="color: #006600;">distance</span><span style="color: #66cc66;">&#40;</span>P,C.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span>Point.<span style="color: #006600;">polar</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan2</span><span style="color: #66cc66;">&#40;</span>C.<span style="color: #006600;">y</span> - D.<span style="color: #006600;">y</span>,C.<span style="color: #006600;">x</span> - D.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> / <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> b:<span style="color: #0066CC;">Number</span>=Point.<span style="color: #006600;">distance</span><span style="color: #66cc66;">&#40;</span>P,C.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span>Point.<span style="color: #006600;">polar</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">-1</span>,<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan2</span><span style="color: #66cc66;">&#40;</span>C.<span style="color: #006600;">y</span> - D.<span style="color: #006600;">y</span>,C.<span style="color: #006600;">x</span> - D.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> / <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	s = a == b;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>a &lt; b<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		f=<span style="color: #000000; font-weight: bold;">true</span>;
	<span style="color: #66cc66;">&#125;</span>
	F=C.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span>Point.<span style="color: #006600;">polar</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan2</span><span style="color: #66cc66;">&#40;</span>C.<span style="color: #006600;">y</span> - D.<span style="color: #006600;">y</span>,C.<span style="color: #006600;">x</span> - D.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	G=C.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span>Point.<span style="color: #006600;">polar</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">-1</span>,<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan2</span><span style="color: #66cc66;">&#40;</span>C.<span style="color: #006600;">y</span> - D.<span style="color: #006600;">y</span>,C.<span style="color: #006600;">x</span> - D.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	a=Point.<span style="color: #006600;">distance</span><span style="color: #66cc66;">&#40;</span>P,F.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span>Point.<span style="color: #006600;">polar</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan2</span><span style="color: #66cc66;">&#40;</span>C.<span style="color: #006600;">y</span> - D.<span style="color: #006600;">y</span>,C.<span style="color: #006600;">x</span> - D.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	b=Point.<span style="color: #006600;">distance</span><span style="color: #66cc66;">&#40;</span>P,G.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span>Point.<span style="color: #006600;">polar</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">-1</span>,<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan2</span><span style="color: #66cc66;">&#40;</span>C.<span style="color: #006600;">y</span> - D.<span style="color: #006600;">y</span>,C.<span style="color: #006600;">x</span> - D.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>a &lt; b<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		r=<span style="color: #000000; font-weight: bold;">true</span>;
	<span style="color: #66cc66;">&#125;</span>
	F=D.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span>Point.<span style="color: #006600;">polar</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan2</span><span style="color: #66cc66;">&#40;</span>C.<span style="color: #006600;">y</span> - D.<span style="color: #006600;">y</span>,C.<span style="color: #006600;">x</span> - D.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	G=D.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span>Point.<span style="color: #006600;">polar</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">-1</span>,<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan2</span><span style="color: #66cc66;">&#40;</span>C.<span style="color: #006600;">y</span> - D.<span style="color: #006600;">y</span>,C.<span style="color: #006600;">x</span> - D.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	a=Point.<span style="color: #006600;">distance</span><span style="color: #66cc66;">&#40;</span>P,F.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span>Point.<span style="color: #006600;">polar</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan2</span><span style="color: #66cc66;">&#40;</span>C.<span style="color: #006600;">y</span> - D.<span style="color: #006600;">y</span>,C.<span style="color: #006600;">x</span> - D.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	b=Point.<span style="color: #006600;">distance</span><span style="color: #66cc66;">&#40;</span>P,G.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span>Point.<span style="color: #006600;">polar</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">-1</span>,<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan2</span><span style="color: #66cc66;">&#40;</span>C.<span style="color: #006600;">y</span> - D.<span style="color: #006600;">y</span>,C.<span style="color: #006600;">x</span> - D.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>a &gt; b<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		l=<span style="color: #000000; font-weight: bold;">true</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>s &amp;&amp; l &amp;&amp; r<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;&quot;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!f &amp;&amp; l &amp;&amp; r<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;behind&quot;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>f &amp;&amp; l &amp;&amp; r<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;front&quot;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>l<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;left&quot;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>r<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;right&quot;</span>;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #ff0000;">&quot;&quot;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2009/05/28/know-where-a-point-is-relevant-to-a-segment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Knowing if a Point is behind a Line</title>
		<link>http://keith-hair.net/blog/2009/05/27/knowing-if-a-point-is-behind-a-line/</link>
		<comments>http://keith-hair.net/blog/2009/05/27/knowing-if-a-point-is-behind-a-line/#comments</comments>
		<pubDate>Wed, 27 May 2009 21:15:01 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[SciFi]]></category>
		<category><![CDATA[Behind]]></category>
		<category><![CDATA[Line]]></category>
		<category><![CDATA[Points]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=58</guid>
		<description><![CDATA[Yea yea, I know Battlestar Galactica is over, but today I thought of the "Daybreak part 1" episode of BSG.
Hera, a little girl has been kidnapped by the Cylons. As part of a desperate plan to save Hera, Admiral Adama draws a red line on the deck, and asks for those willing to risk their [...]]]></description>
			<content:encoded><![CDATA[<p>Yea yea, I know Battlestar Galactica is over, but today I thought of the <a href="http://www.scifi.com/battlestar/episodes/episodes.php?seas=4&#038;ep=421&#038;act=3">"Daybreak part 1" episode of BSG</a>.<br />
Hera, a little girl has been kidnapped by the Cylons. As part of a desperate plan to save Hera, Admiral Adama draws a red line on the deck, and asks for those willing to risk their lives to save her, do so by crossing the line.</p>
<p>I had a similar problem also with my scripts. I wanted to simply know if a Point was behind a Line or not... <img src='http://keith-hair.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_behind_line_917315319"
			class="flashmovie"
			width="550"
			height="400">
	<param name="movie" value="/blog/examples/intersections/behind_line.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/blog/examples/intersections/behind_line.swf"
			name="fm_behind_line_917315319"
			width="550"
			height="400">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><span id="more-58"></span></p>
<pre class="actionscript">&nbsp;
<span style="color: #808080; font-style: italic;">/*-----------------------------------------------------------------
Returns true if Point P is behind line defined by Points C and D.
 ----------------------------------------------------------------*/</span>
<span style="color: #000000; font-weight: bold;">function</span> isBehindLine<span style="color: #66cc66;">&#40;</span>P:Point,C:Point,D:Point<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> a:<span style="color: #0066CC;">Number</span>=Point.<span style="color: #006600;">distance</span><span style="color: #66cc66;">&#40;</span>P,C.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span>Point.<span style="color: #006600;">polar</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan2</span><span style="color: #66cc66;">&#40;</span>C.<span style="color: #006600;">y</span> - D.<span style="color: #006600;">y</span>,C.<span style="color: #006600;">x</span> - D.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> / <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> b:<span style="color: #0066CC;">Number</span>=Point.<span style="color: #006600;">distance</span><span style="color: #66cc66;">&#40;</span>P,C.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span>Point.<span style="color: #006600;">polar</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">-1</span>,<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">atan2</span><span style="color: #66cc66;">&#40;</span>C.<span style="color: #006600;">y</span> - D.<span style="color: #006600;">y</span>,C.<span style="color: #006600;">x</span> - D.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span> / <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #b1b100;">return</span> a &lt; b;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2009/05/27/knowing-if-a-point-is-behind-a-line/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
