﻿<?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 &#187; Flash 9</title>
	<atom:link href="http://keith-hair.net/blog/category/flash-9/feed/" rel="self" type="application/rss+xml" />
	<link>http://keith-hair.net/blog</link>
	<description>Scripting is fun like any other hobby</description>
	<lastBuildDate>Mon, 17 May 2010 16:02:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Resizing Flash Documents to Fit Contents in JSFL</title>
		<link>http://keith-hair.net/blog/2010/03/21/resizing-flash-documents-to-fit-contents-in-jsfl/</link>
		<comments>http://keith-hair.net/blog/2010/03/21/resizing-flash-documents-to-fit-contents-in-jsfl/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 20:04:56 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[JSFL]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[Resize]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=219</guid>
		<description><![CDATA[I use Flex for the majority of my Flash related work, even for writing plain ActionScript. Lately I've barely even used the Flash authoring environment to create stuff. When I do use the Flash authoring environment, it's mostly for automation and prep work of content. If you are like me, you write JSFL to do [...]]]></description>
			<content:encoded><![CDATA[<p>I use Flex for the majority of my Flash related work, even for writing plain ActionScript. Lately I've barely even used the Flash authoring environment to create stuff. When I do use the Flash authoring environment, it's mostly for automation and prep work of content. If you are like me, you write JSFL to do that stuff.</p>
<p>I love automating redundant tasks. One thing that bugs me when importing graphical assets to Flash's stage is having to resize the document to what I imported. I like that I can do this by going to the Document Properties and setting the document to match the content size, but if I have to do this each time I import/export content it becomes a irksome chore. I write JSFL scripts that run tasks on multiple files, having a "match contents"  function would be useful to me in my case...maybe to you as well. I do not see a JSFL way to do this. (Maybe there is and I had a brain fart?). Until then, here is a script I wrote to do it in JSFL...<br />
<span id="more-219"></span></p>
<pre class="brush: jscript;">
/*****************************************************************************************
What:	Document_to_Content_Size.jsfl
		JSFL Command for Flash (8+) that will resize the document to fit the content
		that is on the stage in the authoring environment.

Why:		Yep, this action can also be done by going to the Document Properties
		and setting &quot;match&quot; to &quot;contents&quot;. However, I have not
		found a way to do this same action within JSFL script
		If you know a JSFL way to do this same action easier contact me.		

Date:		March 21, 2010
Author:	Keith Hair
Contact	khos2007@gmail.com
Web:		keith-hair.net		

INSTALL:
		If you deal with JSFL you probably know what to do, but anyway...
		Save this script with a &quot;.jsfl&quot; extension and put in:
		&quot;Your Flash installation folder\en\First Run\Commands&quot; folder
		Or just put it anywhere and double-click the file.

LEGAL STUFF:
		This script is free for whatever, just improve it or say hello! 		

NOTE:
		This is primarily for resizing the Flash
		document to fit content that is imported to the stage.
		Resizing is buggy with Component instances.

******************************************************************************************/
fl.outputPanel.clear();
runApp();
function runApp()
{
	var doc=fl.getDocumentDOM();
	var element;
	var docw=1;
	var doch=1;
	var fn=0;
	var ln=0;
	var en=0;
	var tframes;
	var layer;
	var frame;
	var ox;
	var oy;
	var left=null;
	var right=null;
	var top=null;
	var bottom=null;
	var cf=doc.getTimeline().currentFrame;
	while(ln &lt; doc.getTimeline().layerCount)
	{
		layer=doc.getTimeline().layers[ln];
		tframes=layer.frameCount;
		fn=0;
		while(fn &lt; tframes)
		{
			doc.getTimeline().currentFrame = fn;
			frame=layer.frames[fn];
			en=0;
			while(en &lt; frame.elements.length)
			{
				element = frame.elements[en];
				ox=element.x;
				oy=element.y;
				if(left == null){
					left=ox;
				}
				if(right == null){
					right=ox+element.width;
				}
				if(top == null){
					top=oy;
				}
				if(bottom == null){
					bottom=oy+element.height;
				}

				left=Math.min(ox,left);
				right=Math.max(ox+element.width,right);
				top=Math.min(oy,top);
				bottom=Math.max(oy+element.height,bottom);
				en++;
			}
			fn++;
		}
		ln++;
	}
	fl.trace(&quot;CURRENT SIZE--&gt;\t&quot;+doc.width+&quot; x &quot;+doc.height);
	docw=Math.round(right-left);
	doch=Math.round(bottom-top);
	moveAllElementsBy(-left,-top);
	doc.width=docw;
	doc.height=doch;
	fl.trace(&quot;NEW SIZE--&gt;\t\t\t&quot;+doc.width+&quot; x &quot;+doc.height);
	doc.getTimeline().currentFrame=cf;
}

function moveAllElementsBy(tx,ty)
{
	doc=fl.getDocumentDOM();
	var element;
	var fn=0;
	var ln=0;
	var en=0;
	var tframes;
	var layer;
	var frame;
	var otp;
	while(ln &lt; doc.getTimeline().layerCount)
	{
		layer=doc.getTimeline().layers[ln];
		tframes=layer.frameCount;
		fn=0;
		while(fn &lt; tframes)
		{
			doc.getTimeline().currentFrame = fn;
			frame=layer.frames[fn];
			en=0;
			while(en &lt; frame.elements.length)
			{
				element=frame.elements[en];
				element.x+=tx;
				element.y+=ty;
				if(element.elementType.search(/instance|text/mig) == -1){
					element.x+=element.width/2;
					element.y+=element.height/2;
				}

				en++;
			}
			fn++;
		}
		ln++;
	}

}
</pre>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=&zqz=&zurlz=http://keith-hair.net/blog/2010/03/21/resizing-flash-documents-to-fit-contents-in-jsfl/&ztz=Resizing Flash Documents to Fit Contents in JSFL'><img src='http://keith-hair.net/blog/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a>]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2010/03/21/resizing-flash-documents-to-fit-contents-in-jsfl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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 [...]]]></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_1429952954"
			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_1429952954"
			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>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=&zqz=&zurlz=http://keith-hair.net/blog/2010/02/15/keymanager-class-for-detecting-key-press-combos-or-sequences/&ztz=KeyManager Class for Detecting Key Press Combos or Sequences'><img src='http://keith-hair.net/blog/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a>]]></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>13</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_2087316520"
			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_2087316520"
			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>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=&zqz=&zurlz=http://keith-hair.net/blog/2009/12/08/listing-class-properties-dynamically-in-as3/&ztz=Listing class properties dynamically in AS3'><img src='http://keith-hair.net/blog/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a>]]></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>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 [...]]]></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>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=&zqz=&zurlz=http://keith-hair.net/blog/2009/07/18/do-you-make-tools-to-solve-your-problems/&ztz=Do you make tools to solve your problems?'><img src='http://keith-hair.net/blog/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a>]]></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>Matrix transforms based on an arbitrary registration point</title>
		<link>http://keith-hair.net/blog/2009/01/24/matrix-transforms-based-on-an-arbitrary-registration-point/</link>
		<comments>http://keith-hair.net/blog/2009/01/24/matrix-transforms-based-on-an-arbitrary-registration-point/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 06:05:23 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Arbitrary]]></category>
		<category><![CDATA[Matrix]]></category>
		<category><![CDATA[Registration Point]]></category>
		<category><![CDATA[Skew]]></category>
		<category><![CDATA[Transform]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=28</guid>
		<description><![CDATA[I was wanting a lightweight function to resize, rotate, and skew DisplayObjects based on a dynamic registration point so I made a function to apply my desired matrix settings. One thing that bothers me is that I could not figure out how to skew along the X and Y axis at the same time. When [...]]]></description>
			<content:encoded><![CDATA[<p>I was wanting a lightweight function to resize, rotate, and skew DisplayObjects based on a dynamic registration point so I made a function to apply my desired matrix settings.</p>
<p>One thing that bothers me is that I could not figure out how to skew along the X and Y axis at the same time. When I do set "c" and "b" Matrix properties, one of the skewed axis does not skew parallel like it should. And if I concatenate separate skew Matrices, the last concatenated skew Matrix transforms correctly but not the one before it. I'm trying to avoid using nested DisplayObjects to perform the separate X and Y skews, but that looks like an option I will have to use.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_matrix_example_962006998"
			class="flashmovie"
			width="550"
			height="600">
	<param name="movie" value="/blog/examples/matrix/matrix_example.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/blog/examples/matrix/matrix_example.swf"
			name="fm_matrix_example_962006998"
			width="550"
			height="600">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
<span id="more-28"></span></p>
<pre class="actionscript">&nbsp;
<span style="color: #808080; font-style: italic;">/*---------------------------------------------------------------------------
Sets the transform property of DisplayObject with a customized Matrix.
&nbsp;
display			-An ActionScript DisplayObject.
tx					-Translation x.
ty					-Translation y.
reg				-Registation point from which all transform effects orient from.
ang				-Rotation in in degrees.
scalex				-X scale percentage.
scaley				-Y scale percentage.
skew				-Skew percentage of the DisplayObjects width or height.
axis				-String indicating which axis to skew on.
&nbsp;
Note:	-The &quot;skew&quot; argument only works one axis at a time, If anyone knows
		 how to skew on both X and Y axis at the same time accurately please help me.
&nbsp;
		-The &quot;reg&quot; Registration point get scaled by scalex and scaley.		 
&nbsp;
----------------------------------------------------------------------------*/</span>
<span style="color: #000000; font-weight: bold;">function</span> setDisplayMatrix<span style="color: #66cc66;">&#40;</span>display:DisplayObject,
						  tx:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>,
						  ty:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>,
						  reg:Point=<span style="color: #000000; font-weight: bold;">null</span>,
						  ang:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>,
						  scalex:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">1</span>,
						  scaley:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">1</span>,
						  skew:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;">0</span>,
						  axis:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;x&quot;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	reg=reg||new Point<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> curM:Matrix=<span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> skewM:Matrix=<span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> rotM:Matrix=<span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> scaleM:Matrix=<span style="color: #000000; font-weight: bold;">new</span> Matrix<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> rp:Point;
	<span style="color: #000000; font-weight: bold;">var</span> r:<span style="color: #0066CC;">Number</span>=ang*<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">PI</span>/<span style="color: #cc66cc;">180</span>;
	<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>axis == <span style="color: #ff0000;">&quot;y&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		skewM.<span style="color: #006600;">c</span>=<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">tan</span><span style="color: #66cc66;">&#40;</span>skew<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span>
		skewM.<span style="color: #006600;">b</span>=<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">tan</span><span style="color: #66cc66;">&#40;</span>skew<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span>
	scaleM.<span style="color: #006600;">scale</span><span style="color: #66cc66;">&#40;</span>scalex,scaley<span style="color: #66cc66;">&#41;</span>;
	rotM.<span style="color: #006600;">rotate</span><span style="color: #66cc66;">&#40;</span>r<span style="color: #66cc66;">&#41;</span>;
	curM.<span style="color: #0066CC;">concat</span><span style="color: #66cc66;">&#40;</span>scaleM<span style="color: #66cc66;">&#41;</span>;
	curM.<span style="color: #0066CC;">concat</span><span style="color: #66cc66;">&#40;</span>skewM<span style="color: #66cc66;">&#41;</span>;
	curM.<span style="color: #0066CC;">concat</span><span style="color: #66cc66;">&#40;</span>rotM<span style="color: #66cc66;">&#41;</span>;
	rp=curM.<span style="color: #006600;">transformPoint</span><span style="color: #66cc66;">&#40;</span>reg<span style="color: #66cc66;">&#41;</span>;
	curM.<span style="color: #006600;">tx</span>=-rp.<span style="color: #006600;">x</span>;
	curM.<span style="color: #006600;">ty</span>=-rp.<span style="color: #006600;">y</span>;
	curM.<span style="color: #006600;">tx</span>+=tx;
	curM.<span style="color: #006600;">ty</span>+=ty;
	display.<span style="color: #006600;">transform</span>.<span style="color: #006600;">matrix</span>=curM;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>Here is a diagram I made to show what kind of skew I wanted to achieve instead of only skewing one axis at a time:<br />
<img src="/blog/examples/matrix/skew_diagram.gif" alt="The type of skews I want to achieve." /></p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=&zqz=&zurlz=http://keith-hair.net/blog/2009/01/24/matrix-transforms-based-on-an-arbitrary-registration-point/&ztz=Matrix transforms based on an arbitrary registration point'><img src='http://keith-hair.net/blog/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a>]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2009/01/24/matrix-transforms-based-on-an-arbitrary-registration-point/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Line to Circle Intersection data</title>
		<link>http://keith-hair.net/blog/2008/08/05/line-to-circle-intersection-data/</link>
		<comments>http://keith-hair.net/blog/2008/08/05/line-to-circle-intersection-data/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 07:45:17 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Circle]]></category>
		<category><![CDATA[Intersection]]></category>
		<category><![CDATA[Line]]></category>

		<guid isPermaLink="false">http://keith-hair.com/blog/?p=23</guid>
		<description><![CDATA[Here is an ActionScript 3 function that will return intersection information between a segment and circle. It's useful to me to know if a segment is partially intersecting with a circle or going completely through. 
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_line_to_circle_intersection_2005748249"
			class="flashmovie"
			width="550"
			height="400">
	<param name="movie" value="/blog/examples/intersections/line_to_circle_intersection.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/blog/examples/intersections/line_to_circle_intersection.swf"
			name="fm_line_to_circle_intersection_2005748249"
			width="550"
			height="400">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object> &#160; /*--------------------------------------------------------------------------- Returns an Object with the following properties: enter -Intersection Point entering the circle. [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an ActionScript 3 function that will return intersection information between a segment and circle.<br />
It's useful to me to know if a segment is partially intersecting with a circle or going completely through.<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_line_to_circle_intersection_1583243660"
			class="flashmovie"
			width="550"
			height="400">
	<param name="movie" value="/blog/examples/intersections/line_to_circle_intersection.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/blog/examples/intersections/line_to_circle_intersection.swf"
			name="fm_line_to_circle_intersection_1583243660"
			width="550"
			height="400">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
<span id="more-23"></span></p>
<pre class="actionscript">&nbsp;
<span style="color: #808080; font-style: italic;">/*---------------------------------------------------------------------------
Returns an Object with the following properties:
	enter			-Intersection Point entering the circle.
	exit			-Intersection Point exiting the circle.
	inside			-Boolean indicating if the points of the line are inside the circle.
	tangent		-Boolean indicating if line intersect at one point of the circle.
	intersects		-Boolean indicating if there is an intersection of the points and the circle.
&nbsp;
If both &quot;enter&quot; and &quot;exit&quot; are null, or &quot;intersects&quot; == false, it indicates there is no intersection.
&nbsp;
This is a customization of the intersectCircleLine Javascript function found here:
&nbsp;
http://www.kevlindev.com/gui/index.htm
&nbsp;
----------------------------------------------------------------------------*/</span>
<span style="color: #000000; font-weight: bold;">function</span> lineIntersectCircle<span style="color: #66cc66;">&#40;</span>A : Point, B : Point, C : Point, r : <span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Object</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> result : <span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	result.<span style="color: #006600;">inside</span> = <span style="color: #000000; font-weight: bold;">false</span>;
	result.<span style="color: #006600;">tangent</span> = <span style="color: #000000; font-weight: bold;">false</span>;
	result.<span style="color: #006600;">intersects</span> = <span style="color: #000000; font-weight: bold;">false</span>;
	result.<span style="color: #0066CC;">enter</span>=<span style="color: #000000; font-weight: bold;">null</span>;
	result.<span style="color: #006600;">exit</span>=<span style="color: #000000; font-weight: bold;">null</span>;
	<span style="color: #000000; font-weight: bold;">var</span> a : <span style="color: #0066CC;">Number</span> = <span style="color: #66cc66;">&#40;</span>B.<span style="color: #006600;">x</span> - A.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #66cc66;">&#40;</span>B.<span style="color: #006600;">x</span> - A.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #66cc66;">&#40;</span>B.<span style="color: #006600;">y</span> - A.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #66cc66;">&#40;</span>B.<span style="color: #006600;">y</span> - A.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> b : <span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">2</span> * <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>B.<span style="color: #006600;">x</span> - A.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #66cc66;">&#40;</span>A.<span style="color: #006600;">x</span> - C.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> +<span style="color: #66cc66;">&#40;</span>B.<span style="color: #006600;">y</span> - A.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #66cc66;">&#40;</span>A.<span style="color: #006600;">y</span> - C.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> cc : <span style="color: #0066CC;">Number</span> = C.<span style="color: #006600;">x</span> * C.<span style="color: #006600;">x</span> + C.<span style="color: #006600;">y</span> * C.<span style="color: #006600;">y</span> + A.<span style="color: #006600;">x</span> * A.<span style="color: #006600;">x</span> + A.<span style="color: #006600;">y</span> * A.<span style="color: #006600;">y</span> - <span style="color: #cc66cc;">2</span> * <span style="color: #66cc66;">&#40;</span>C.<span style="color: #006600;">x</span> * A.<span style="color: #006600;">x</span> + C.<span style="color: #006600;">y</span> * A.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span> - r * r;
	<span style="color: #000000; font-weight: bold;">var</span> deter : <span style="color: #0066CC;">Number</span> = b * b - <span style="color: #cc66cc;">4</span> * a * cc;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>deter &lt;= <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		result.<span style="color: #006600;">inside</span> = <span style="color: #000000; font-weight: bold;">false</span>;
	<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">e</span> : <span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sqrt</span> <span style="color: #66cc66;">&#40;</span>deter<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000000; font-weight: bold;">var</span> u1 : <span style="color: #0066CC;">Number</span> = <span style="color: #66cc66;">&#40;</span> - b + <span style="color: #0066CC;">e</span> <span style="color: #66cc66;">&#41;</span> / <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span> * a <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000000; font-weight: bold;">var</span> u2 : <span style="color: #0066CC;">Number</span> = <span style="color: #66cc66;">&#40;</span> - b - <span style="color: #0066CC;">e</span> <span style="color: #66cc66;">&#41;</span> / <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span> * a <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>u1 &lt; <span style="color: #cc66cc;">0</span> || u1 &gt; <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; <span style="color: #66cc66;">&#40;</span>u2 &lt; <span style="color: #cc66cc;">0</span> || u2 &gt; <span style="color: #cc66cc;">1</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><span style="color: #66cc66;">&#40;</span>u1 &lt; <span style="color: #cc66cc;">0</span> &amp;&amp; u2 &lt; <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> || <span style="color: #66cc66;">&#40;</span>u1 &gt; <span style="color: #cc66cc;">1</span> &amp;&amp; u2 &gt; <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				result.<span style="color: #006600;">inside</span> = <span style="color: #000000; font-weight: bold;">false</span>;
			<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
				result.<span style="color: #006600;">inside</span> = <span style="color: #000000; font-weight: bold;">true</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>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span> &lt;= u2 &amp;&amp; u2 &lt;= <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				result.<span style="color: #0066CC;">enter</span>=Point.<span style="color: #006600;">interpolate</span> <span style="color: #66cc66;">&#40;</span>A, B, <span style="color: #cc66cc;">1</span> - u2<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span> &lt;= u1 &amp;&amp; u1 &lt;= <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				result.<span style="color: #006600;">exit</span>=Point.<span style="color: #006600;">interpolate</span> <span style="color: #66cc66;">&#40;</span>A, B, <span style="color: #cc66cc;">1</span> - u1<span style="color: #66cc66;">&#41;</span>;
			<span style="color: #66cc66;">&#125;</span>
			result.<span style="color: #006600;">intersects</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>result.<span style="color: #006600;">exit</span> != <span style="color: #000000; font-weight: bold;">null</span> &amp;&amp; result.<span style="color: #0066CC;">enter</span> != <span style="color: #000000; font-weight: bold;">null</span> &amp;&amp; result.<span style="color: #006600;">exit</span>.<span style="color: #006600;">equals</span> <span style="color: #66cc66;">&#40;</span>result.<span style="color: #0066CC;">enter</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				result.<span style="color: #006600;">tangent</span> = <span style="color: #000000; font-weight: bold;">true</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">return</span> result;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=&zqz=&zurlz=http://keith-hair.net/blog/2008/08/05/line-to-circle-intersection-data/&ztz=Line to Circle Intersection data'><img src='http://keith-hair.net/blog/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a>]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2008/08/05/line-to-circle-intersection-data/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Find Intersection Point of two lines in AS3</title>
		<link>http://keith-hair.net/blog/2008/08/04/find-intersection-point-of-two-lines-in-as3/</link>
		<comments>http://keith-hair.net/blog/2008/08/04/find-intersection-point-of-two-lines-in-as3/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 04:07:43 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash 9]]></category>
		<category><![CDATA[Intersection]]></category>

		<guid isPermaLink="false">http://keith-hair.com/blog/?p=22</guid>
		<description><![CDATA[The intersection Point of two lines is useful to know. This is a function to find it in AS3. 
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_line_to_line_intersection_1246695415"
			class="flashmovie"
			width="550"
			height="550">
	<param name="movie" value="/blog/examples/intersections/line_to_line_intersection.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/blog/examples/intersections/line_to_line_intersection.swf"
			name="fm_line_to_line_intersection_1246695415"
			width="550"
			height="550">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object> //--------------------------------------------------------------- //Checks for intersection of Segment if as_seg is true. //Checks for intersection of Line if as_seg is false. //Return intersection of Segment AB and Segment EF as a Point //Return [...]]]></description>
			<content:encoded><![CDATA[<p>The intersection Point of two lines is useful to know. This is a function to find it in AS3.</p>
<p style="text-align: center;">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_line_to_line_intersection_1410511619"
			class="flashmovie"
			width="550"
			height="550">
	<param name="movie" value="/blog/examples/intersections/line_to_line_intersection.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/blog/examples/intersections/line_to_line_intersection.swf"
			name="fm_line_to_line_intersection_1410511619"
			width="550"
			height="550">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
<span id="more-22"></span></p>
<pre class="brush: as3;">
//---------------------------------------------------------------
//Checks for intersection of Segment if as_seg is true.
//Checks for intersection of Line if as_seg is false.
//Return intersection of Segment AB and Segment EF as a Point
//Return null if there is no intersection
//---------------------------------------------------------------
function lineIntersectLine(A:Point,B:Point,E:Point,F:Point,as_seg:Boolean=true):Point {
    var ip:Point;
    var a1:Number;
    var a2:Number;
    var b1:Number;
    var b2:Number;
    var c1:Number;
    var c2:Number;

    a1= B.y-A.y;
    b1= A.x-B.x;
    c1= B.x*A.y - A.x*B.y;
    a2= F.y-E.y;
    b2= E.x-F.x;
    c2= F.x*E.y - E.x*F.y;

    var denom:Number=a1*b2 - a2*b1;
    if (denom == 0) {
        return null;
    }
    ip=new Point();
    ip.x=(b1*c2 - b2*c1)/denom;
    ip.y=(a2*c1 - a1*c2)/denom;

    //---------------------------------------------------
    //Do checks to see if intersection to endpoints
    //distance is longer than actual Segments.
    //Return null if it is with any.
    //---------------------------------------------------
    if(as_seg){
        if(Math.pow(ip.x - B.x, 2) + Math.pow(ip.y - B.y, 2) &gt; Math.pow(A.x - B.x, 2) + Math.pow(A.y - B.y, 2))
        {
           return null;
        }
        if(Math.pow(ip.x - A.x, 2) + Math.pow(ip.y - A.y, 2) &gt; Math.pow(A.x - B.x, 2) + Math.pow(A.y - B.y, 2))
        {
           return null;
        }

        if(Math.pow(ip.x - F.x, 2) + Math.pow(ip.y - F.y, 2) &gt; Math.pow(E.x - F.x, 2) + Math.pow(E.y - F.y, 2))
        {
           return null;
        }
        if(Math.pow(ip.x - E.x, 2) + Math.pow(ip.y - E.y, 2) &gt; Math.pow(E.x - F.x, 2) + Math.pow(E.y - F.y, 2))
        {
           return null;
        }
    }
    return ip;
}
</pre>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=&zqz=&zurlz=http://keith-hair.net/blog/2008/08/04/find-intersection-point-of-two-lines-in-as3/&ztz=Find Intersection Point of two lines in AS3'><img src='http://keith-hair.net/blog/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a>]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2008/08/04/find-intersection-point-of-two-lines-in-as3/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Superman flash test</title>
		<link>http://keith-hair.net/blog/2008/07/17/superman-flash-test/</link>
		<comments>http://keith-hair.net/blog/2008/07/17/superman-flash-test/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 05:05:04 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flash 9]]></category>

		<guid isPermaLink="false">http://keith-hair.com/blog/?p=19</guid>
		<description><![CDATA[Here is a scrolling background and keyboard control test for some AS3 classes I been working on. I used the image of superman from some sprite graphics I found on the web. The images for his flight positions are loaded dynamically. This is for allowing me to load other images for different characters without changing [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a scrolling background and keyboard control test for some AS3 classes I been working on. I used the image of superman from some sprite graphics I <a href="http://spritedatabase.net/">found</a> on the web. The images for his flight positions are loaded dynamically. This is for allowing me to load other images for different characters without changing too much script.</p>
<p><a href="/blog/examples/superman"><img src="/blog/examples/superman/superman.jpg" alt="Superman Flash test" /></a></p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=&zqz=&zurlz=http://keith-hair.net/blog/2008/07/17/superman-flash-test/&ztz=Superman flash test'><img src='http://keith-hair.net/blog/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a>]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2008/07/17/superman-flash-test/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
