<?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>h6 - HatSix &#187; AIR</title>
	<atom:link href="http://hat6.com/category/projects/air/feed/" rel="self" type="application/rss+xml" />
	<link>http://hat6.com</link>
	<description>Hat6 Web Application Engineering</description>
	<lastBuildDate>Fri, 12 Mar 2010 17:13: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>Singleton-esque, self-aware &#8216;Kind&#8217; Classes</title>
		<link>http://hat6.com/2008/09/08/singleton-esque-self-aware-kind-classes/</link>
		<comments>http://hat6.com/2008/09/08/singleton-esque-self-aware-kind-classes/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 00:49:46 +0000</pubDate>
		<dc:creator>Dusty</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://hat6.com/?p=26</guid>
		<description><![CDATA[I recently started a project of converting an older flex app to an AIR app. This app has to scan through a bunch of files, and classify certain types of media based on the location and file extension.  Then it saves a manifest of the media to an xml file that can be loaded [...]]]></description>
			<content:encoded><![CDATA[<p>I recently started a project of converting an older flex app to an AIR app. This app has to scan through a bunch of files, and classify certain types of media based on the location and file extension.  Then it saves a manifest of the media to an xml file that can be loaded (without scanning every time).</p>
<p>I started out with a Kind class (think CollectionEventKind) that had the types as strings&#8230; but then I had to figure out how to store the regular expressions to make them easily accessible&#8230; Then I remembered that while everyone just uses Strings, static const vars can be any class, including it&#8217;s own class.  So I came up with this class that you can use constants, or locate a specific constant.  Code after the fold.<br />
<span id="more-26"></span><br />
<code><br />
package aero.panasonic.training.model<br />
{<br />
	import flash.utils.Dictionary;<br />
	import flash.utils.describeType;</p>
<p>	public class MediaKind<br />
	{<br />
		public function MediaKind(title:String, label:String, regex:RegExp ){<br />
			this.title = title;<br />
			this.label = label;<br />
			this.regex = regex;<br />
		}<br />
		public function toString():String{<br />
			return title;<br />
		}<br />
		public var title:String;<br />
		public var label:String;<br />
		public var regex:RegExp;<br />
		public static const D_ILLUSTRATION_PERSPECTIVE:MediaKind =<br />
			new MediaKind("Illustration - Perspective", "Perspective", /Deliverables\/Illustrations\/Perspective\/.*_perspective\.(?:png|swf|jpg)/i );<br />
		public static const D_ILLUSTRATION_THREEQUARTER:MediaKind =<br />
			new MediaKind("Illustration - 3/4 (ISO)", "ISO", /Deliverables\/Illustrations\/Isometric\/.*_iso\.(?:png|swf|jpg)/i );</p>
<p>		private static var lookup:Dictionary = new Dictionary();<br />
		private static var allKinds:Array = new Array();<br />
		private static var kindsMapped:Boolean = false;</p>
<p>		private static function mapKinds():void{<br />
			var description:XML = describeType(MediaKind);<br />
			for each(var cXML:XML in description.constant){<br />
				var m:MediaKind = MediaKind[cXML.@name] as MediaKind;<br />
				lookup[m.title] = m;<br />
				lookup[m.label] = m;<br />
				allKinds.push(m);<br />
			}<br />
			kindsMapped = true;<br />
		}<br />
		public static function getMediaKind(input:String):MediaKind{<br />
			if(!kindsMapped) mapKinds();<br />
			return lookup[input];<br />
		}<br />
		public static function getAllKinds():Array{<br />
			if(!kindsMapped) mapKinds();<br />
			return allKinds;<br />
		}<br />
	}<br />
}<br />
</code></p>
<p>In my code, I have a piece that gets all of the MediaKinds, then checks each file against each kind. I can filter, I can create drop-downs, all from one class.  The getMediaKind() function lets me effortlessly create my ValueObjects from XML. The toString() writes out the title, making my XML human-readable.</p>
<p>Instinctively, I want to take this farther and create a base &#8216;Kind&#8217; class that has this all in it. It turns out that static properties/functions aren&#8217;t inherited. The properties and functions are still in scope, however&#8230; so it may be possible to write a generic function that takes a class, creates a lookup for that specific class and passes it back down the line, allowing the allKinds() function to return ALL of the static definitions for the class and it&#8217;s super-classes.  Anyways, that&#8217;s too much for my head at this point, but maybe someone else will take the bait <img src='http://hat6.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://hat6.com/2008/09/08/singleton-esque-self-aware-kind-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging AIR Drag and Drop</title>
		<link>http://hat6.com/2008/05/11/debugging-air-drag-and-drop/</link>
		<comments>http://hat6.com/2008/05/11/debugging-air-drag-and-drop/#comments</comments>
		<pubDate>Sun, 11 May 2008 23:59:03 +0000</pubDate>
		<dc:creator>Dusty</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://hat6.com/2008/05/11/debugging-air-drag-and-drop/</guid>
		<description><![CDATA[So&#8230; you thought you&#8217;d be cool and throw a break point on some DRAG_ENTER code, but after you&#8217;re done debugging, you&#8217;re left with a little floating icon on your desktop.

Never fear, you don&#8217;t have to restart your entire computer, open up Taskmanager and you&#8217;ll see an application called &#8216;Drag&#8217;.  You can kill this application [...]]]></description>
			<content:encoded><![CDATA[<p>So&#8230; you thought you&#8217;d be cool and throw a break point on some DRAG_ENTER code, but after you&#8217;re done debugging, you&#8217;re left with a little floating icon on your desktop.</p>
<p><img src="http://hat6.com/wp-content/uploads/2008/05/debugging_dragdrop.png" alt="Debugging Drag and Drop" /></p>
<p>Never fear, you don&#8217;t have to restart your entire computer, open up Taskmanager and you&#8217;ll see an application called &#8216;Drag&#8217;.  You can kill this application and the icon will disappear.  If you don&#8217;t see this app, close Eclipse and find the process called &#8216;adl.exe&#8217; and kill this process.</p>
<p>Restart averted, Yay!</p>
]]></content:encoded>
			<wfw:commentRss>http://hat6.com/2008/05/11/debugging-air-drag-and-drop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
