﻿<?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; Flex</title>
	<atom:link href="http://keith-hair.net/blog/category/flex/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_685094354"
			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_685094354"
			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>1</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_1721679295"
			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_1721679295"
			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_1146973273"
			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_1146973273"
			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>Letting DisplayObjects Find the Main WindowedApplication in AIR</title>
		<link>http://keith-hair.net/blog/2009/04/30/letting-displayobjects-find-the-main-windowedapplication-in-air/</link>
		<comments>http://keith-hair.net/blog/2009/04/30/letting-displayobjects-find-the-main-windowedapplication-in-air/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 20:48:59 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Cursor]]></category>
		<category><![CDATA[WindowedApplication]]></category>

		<guid isPermaLink="false">http://keith-hair.net/blog/?p=29</guid>
		<description><![CDATA[Here is a way to let a DisplayObject find the main WindowedApplication on its own...
In my AIR application I have other AIR Windows floating over the main AIR Window.
I wanted one of my UIComponents to be draggable like a cursor, but when my mouse dragged the object
over the other floating windows I wanted my original [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a way to let a DisplayObject find the main WindowedApplication on its own...</p>
<p>In my AIR application I have other AIR Windows floating over the main AIR Window.<br />
I wanted one of my UIComponents to be draggable like a cursor, but when my mouse dragged the object<br />
over the other floating windows I wanted my original cursor to show again and hide my dragged UIComponent.</p>
<p>The reason behind this is if I wanted to apply "context sensitive" behaviors depending on what or which window the mouse is in.</p>
<p>To do this, the main WindowedApplication needed some ROLL_OUT and ROLL_OVER events added to it to detect when the mouse rolls in and out.<br />
The "getAIRAppWindow" method below finds the main WindowedApplication so I can add the listeners to it from there.</p>
<p>Here are some snippets explaining what I did:</p>
<p><span id="more-29"></span></p>
<p><strong>The method needed to find main WindowedApplication</strong></p>
<pre class="actionscript">&nbsp;
<span style="color: #808080; font-style: italic;">/*----------------------------------------------------------
Finds the main WindowedApplication of an AIR application
from any UIComponent and returns it.
------------------------------------------------------------*/</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getAIRAppWindow<span style="color: #66cc66;">&#40;</span>p:DisplayObjectContainer<span style="color: #66cc66;">&#41;</span>:WindowedApplication
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> c:*=p;
	<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>c.<span style="color: #006600;">parent</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 is WindowedApplication<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
					<span style="color: #b1b100;">return</span> WindowedApplication<span style="color: #66cc66;">&#40;</span>c<span style="color: #66cc66;">&#41;</span>;
				<span style="color: #66cc66;">&#125;</span>
			c=c.<span style="color: #006600;">parent</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">null</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p><strong><br />
Adding events to detect mouse in main Windowed Application</strong></p>
<pre class="actionscript">&nbsp;
_windowedApp=getAIRAppWindow<span style="color: #66cc66;">&#40;</span>parent<span style="color: #66cc66;">&#41;</span>;
&nbsp;
_windowedApp.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">ROLL_OUT</span>,__onMouseOutWorkSpace<span style="color: #66cc66;">&#41;</span>;
_windowedApp.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">ROLL_OVER</span>,__onMouseInWorkSpace<span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p><strong><br />
Example of actions to apply on ROLL_OUT and ROLL_OVER</strong></p>
<pre class="actionscript">&nbsp;
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> __onMouseOutWorkSpace<span style="color: #66cc66;">&#40;</span>evt:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">/*--------------------------------------------------------
	When your mouse rolls out of the main WindowedApplication
	(and into other nested Windows) you can make your regular
	mouse cursor show again here, while hiding your custom cursor.
	----------------------------------------------------------*/</span>
	yourCustomCursor.<span style="color: #0066CC;">visible</span>=<span style="color: #000000; font-weight: bold;">false</span>;
	<span style="color: #0066CC;">Mouse</span>.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> __onMouseInWorkSpace<span style="color: #66cc66;">&#40;</span>evt:MouseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">/*--------------------------------------------------------
	When your mouse rolls back in the main WindowedApplication
	(and out of other nested Windows) you can hide your regular
	mouse cursor, while showing your custom cursor again.
	----------------------------------------------------------*/</span>
	yourCustomCursor.<span style="color: #0066CC;">visible</span>=<span style="color: #000000; font-weight: bold;">true</span>;
	<span style="color: #0066CC;">Mouse</span>.<span style="color: #0066CC;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2009/04/30/letting-displayobjects-find-the-main-windowedapplication-in-air/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nice Knobs &#8230;for Flex</title>
		<link>http://keith-hair.net/blog/2008/07/25/nice-knobs/</link>
		<comments>http://keith-hair.net/blog/2008/07/25/nice-knobs/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 09:31:06 +0000</pubDate>
		<dc:creator>Keith H</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Components]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[dial]]></category>
		<category><![CDATA[gauge]]></category>
		<category><![CDATA[knob]]></category>
		<category><![CDATA[rotary]]></category>

		<guid isPermaLink="false">http://keith-hair.com/blog/?p=20</guid>
		<description><![CDATA[Here is a Flex UI component I've been writing. Click the image to play with what I have made so far.
You can change a variety of properties. The dial and mark are runtime skinnable by setting its "dialBackgroundSkin" or "dialMarkSkin" property to a url with an image. 
Knobs and dials just look cool...I don't know anything [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a <a href="/blog/examples/niceknobs" target="_blank">Flex UI component</a> I've been writing. Click the image to play with what I have made so far.<br />
You can change a variety of properties. The dial and mark are runtime skinnable by setting its "dialBackgroundSkin" or "dialMarkSkin" property to a url with an image. <strong></strong></p>
<p>Knobs and dials just look cool...I don't know anything about audio editing but I like the site of a sound studio. This is the "<a href="http://www.propellerheads.se/">Reason</a>" I decided to make a knob component.</p>
<p style="text-align: center;"><a href="http:/blog/examples/niceknobs" target="_blank"><img class="alignnone aligncenter" src="/blog/examples/niceknobs/niceknobs.jpg" alt="Nice Knobs" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://keith-hair.net/blog/2008/07/25/nice-knobs/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
