<?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>bustardcelly &#187; Apollo</title>
	<atom:link href="http://custardbelly.com/blog/?feed=rss2&#038;cat=9" rel="self" type="application/rss+xml" />
	<link>http://custardbelly.com/blog</link>
	<description>it&#039;s a long story</description>
	<lastBuildDate>Tue, 24 Aug 2010 14:25:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Looking back and looking forward</title>
		<link>http://custardbelly.com/blog/?p=69</link>
		<comments>http://custardbelly.com/blog/?p=69#comments</comments>
		<pubDate>Sun, 24 Feb 2008 15:22:28 +0000</pubDate>
		<dc:creator>todd anderson</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Apollo]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Infrared5]]></category>
		<category><![CDATA[Red5]]></category>

		<guid isPermaLink="false">http://custardbelly.com/blog/?p=69</guid>
		<description><![CDATA[For those of you that still follow this blog, you may have noticed that i have not been too knee-deep in blogging. A measly 5 posts ago, i rambled on about what 2007 might bring. Needless to say it had kept me pretty busy &#8211; and for all good reason. I have had the opportunity [...]]]></description>
			<content:encoded><![CDATA[<p>For those of you that still follow this blog, you may have noticed that i have not been too knee-deep in blogging. A measly 5 posts ago, <a href="http://custardbelly.com/blog/?p=58" target="_blank">i rambled on</a> about what 2007 might bring. Needless to say it had kept me pretty busy &#8211; and for all good reason. I have had the opportunity to work alongside some unbelievably talented people and be a part of two amazing books focused on <a href="http://labs.adobe.com/technologies/air/" target="_blank">Adobe AIR</a> and <a href="http://labs.adobe.com/technologies/flex/" target="_blank">Flex 3</a> that will be hitting shelves soon. I also accepted a position at <a href="http://www.infrared5.com" target="_blank">Infrared5</a> and am looking forward to working with some of the most insane and brilliant minds in the industry.</p>
<p><a href="http://www.amazon.com/Adobe-AIR-Create-Modify-Reuse/dp/0470182075/ref=pd_bbs_sr_8?ie=UTF8&#038;s=books&#038;qid=1203806020&#038;sr=8-8"><img src="http://www.custardbelly.com/blog/images/air_cmr.jpg" alt="AIR Create-Modify-Reuse" /></a><br />
Marc Leuchner and Matt Wright (of <a href="http://blog.nobien.net/" target="_blank">NoBien</a> fame) and I have been burning the midnight oil to deliver an exciting book on <a href="http://www.amazon.com/Adobe-AIR-Create-Modify-Reuse/dp/0470182075/ref=pd_bbs_sr_8?ie=UTF8&#038;s=books&#038;qid=1203806020&#038;sr=8-8">Adobe AIR &#8211; AIR Create-Reuse-Modify</a> from Wiley Wrox press. Each chapter walks through building applications as you learn about the AIR API. We had a lot of fun architecting and writing about each application that highlights specific facets of the platform and hope it is as much fun to read. Adobe AIR and the API is part of the Flex 3 SDK, which might be <a href="http://www.onflex.org/ted/2008/02/flex-30-and-air-10-are-days-away.php" target="_blank">coming out soon</a>&#8230;</p>
<p><a href="http://www.amazon.com/Flex-3-Cookbook-Joshua-Noble/dp/0596529856/ref=pd_bbs_sr_1?ie=UTF8&#038;s=books&#038;qid=1203806666&#038;sr=8-1"><img src="http://www.custardbelly.com/blog/images/cookbook.jpg" alt="Flex 3 cookbook" /></a><br />
Well, i didn&#8217;t stop at discussing one part of the Flex 3 SDK and also was asked by <a href="http://thefactoryfactory.com/wordpress/" target="_blank">Josh Noble</a> to be a co-author for the <a href="http://www.amazon.com/Flex-3-Cookbook-Joshua-Noble/dp/0596529856/ref=pd_bbs_sr_1?ie=UTF8&#038;s=books&#038;qid=1203806666&#038;sr=8-1">Flex 3 Cookbook</a> from the O&#8217;Reilly press. We&#8217;ve gathered the submissions from the Adobe <a href="http://www.adobe.com/cfusion/communityengine/index.cfm?event=homepage&#038;productId=2" target="_blank">online cookbook</a> and Josh has been steering the cookbook ship to greatness. If you are unfamiliar with the <a href="http://www.oreilly.com/store/series/cookbooks.csp" target="_blank">O&#8217;Reilly cookbook</a> format, the book is designed to present hundreds of &#8216;recipes&#8217; aimed at solving programming problems. I have had the extreme pleasure to write about parts of the Flex API that i love and believe to be essential to RIAs developed using the Flash Platform.</p>
<p>If writing didn&#8217;t keep me busy enough, I worked with some amazing people while building applications that stretched the possibilities of what online and desktop applications built in Flex can do. Along the way i learned more about the business, some agile practices (which i hope to write about some) and how to have fun and love what i do. It is an amazing thing.</p>
<p><a href="http://infrared5.com" target="_blank"><img src="http://www.custardbelly.com/blog/images/infrared5.gif" alt="Infrared5" /></a><br />
I also have had the opportunity to join the <a href="http://www.infrared5.com" target="_blank">Infrared5</a> team and could not be happier. Infrared5 is a consulting company started by Chris Allen, Rebecca Allen and Dominick Accattato focused on architecting applications using the Flash Platform and Red5 Server technologies. <a href="http://bit-101.com/blog" target="_blank">Keith</a> summed it up pretty well <a href="http://www.bit-101.com/blog/?p=1163#comments">in this post</a>. I am honored to be in company with some of the brightest minds in the field that keep me laughing throughout the day. Once I stop breaking things around the office, i can settle in and learn something <img src='http://darko.liquidweb.com/~custardb/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>All in all, 2007 was a great year and i am making out 2008 to be even better. Here&#8217;s to posting more!</p>
]]></content:encoded>
			<wfw:commentRss>http://custardbelly.com/blog/?feed=rss2&amp;p=69</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AIR InvokeEvent and FileTypes</title>
		<link>http://custardbelly.com/blog/?p=62</link>
		<comments>http://custardbelly.com/blog/?p=62#comments</comments>
		<pubDate>Fri, 05 Oct 2007 13:24:46 +0000</pubDate>
		<dc:creator>todd anderson</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Apollo]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://custardbelly.com/blog/?p=62</guid>
		<description><![CDATA[As some of you may know, Matt Wright and Marc Leuchner (of nobien fame) and I are authoring an Adobe AIR book to be published by Wiley. We&#8217;ve been breaking fingernails typing away to deliver a jam-packed by-examples book in which you&#8217;ll build real world applications while learning about the AIR API. As we&#8217;re writing, [...]]]></description>
			<content:encoded><![CDATA[<p>As some of you may know, <a href="http://www.designhonky.com/" target="_blank">Matt Wright</a> and <a href="http://www.forwardatlantic.com/marc/2006/" target="_blank">Marc Leuchner</a> (of <a href="http://blog.nobien.net/" target="_blank">nobien</a> fame) and I are authoring an <a href="http://www.amazon.com/Adobe-AIR-Create-Modify-Reuse/dp/0470182075/ref=pd_bbs_sr_6/002-5985048-8156021?ie=UTF8&#038;s=books&#038;qid=1191543407&#038;sr=8-6" target="_blank">Adobe AIR book</a> to be published by <a href="http://www.wiley.com/WileyCDA/" target="_blank">Wiley</a>. We&#8217;ve been breaking fingernails typing away to deliver a jam-packed by-examples book in which you&#8217;ll build real world applications while learning about the AIR API. As we&#8217;re writing, we run across some amazing features in AIR and yammer amongst ourselves &#8211; or to anyone who listens &#8211; but rarely blog about our excitement and findings.</p>
<p>That said, there is a coupling of features of AIR while leveraging the Flex Framework that i cannot hold inside and think is worth mentioning: Associated filetypes, the invoke event, and BindingUtils. </p>
<p><em>To view and download the full code, <a href="http://custardbelly.com/downloads/air/FileTypeFun" target="blank">click here</a>.<br />
</em><br />
<strong>File Types</strong><br />
First off, you can associate filetypes to your AIR app in the application descriptor file within the <code>fileTypes</code> node:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;filetypes<span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;">&lt;filetype<span style="color: #7400FF;">&gt;</span></span>
      <span style="color: #000000;">&lt;name<span style="color: #7400FF;">&gt;</span></span>com.example<span style="color: #000000;">&lt;/name<span style="color: #7400FF;">&gt;</span></span>
      <span style="color: #000000;">&lt;extension<span style="color: #7400FF;">&gt;</span></span>ftf<span style="color: #000000;">&lt;/extension<span style="color: #7400FF;">&gt;</span></span>
      <span style="color: #000000;">&lt;description<span style="color: #7400FF;">&gt;</span></span>FileTypeFun file<span style="color: #000000;">&lt;/description<span style="color: #7400FF;">&gt;</span></span>
      <span style="color: #000000;">&lt;contenttype<span style="color: #7400FF;">&gt;</span></span>text/plain<span style="color: #000000;">&lt;/contenttype<span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;">&lt;/filetype<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;">&lt;/filetypes<span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Once the AIR app is installed on your machine, a file with the extension set as the value of the <code>extension</code> node will be associated with your app. Meaning, it will show up first in the list when you choose &#8216;open with&#8217; and even invoke the app if you double-click on the file &#8211; that is if the extension is not associated with another program on your machine (ie. doc) in which case you will have to set your app to always open associated as default to your app.</p>
<p><strong>InvokeEvent</strong><br />
The invoke event of a <code>WindowedApplication</code> will be triggered upon initial instantiation &#8211; without having the application previously running &#8211; and any subsequent &#8216;open with file&#8217; calls. The arguments property of the <code>InvokeEvent</code> is an array of arguments passed through invocation of the app. This not only allows command line junkies to open an application with a file like so:</p>
<p><em>On Mac:</em><br />
>open MyAirApp.app MyDocuments.ftf<br />
<em><br />
On Windows:</em><br />
>MyAirApp MyDocument.ftf</p>
<p>.. but as well as double-clicking or choosing &#8216;open with&#8217; on a file (as describe above). Probably you wouldn&#8217;t have any documents lying around in your applications directory &#8211; but you get the picture. To handle those arguments your app would look something like as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt; ?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;">&lt;mx :WindowedApplication </span>
<span style="color: #000000;">    xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">    layout=<span style="color: #ff0000;">&quot;vertical&quot;</span> </span>
<span style="color: #000000;">    horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #000000;">    invoke=<span style="color: #ff0000;">&quot;onAppInvoke(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;">&lt;/mx<span style="color: #7400FF;">&gt;</span>&lt;mx :Script<span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt; !<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            private function onAppInvoke<span style="color: #66cc66;">&#40;</span> evt:InvokeEvent <span style="color: #66cc66;">&#41;</span>:void</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                var items:Array = evt.arguments;</span>
<span style="color: #000000;">                for<span style="color: #66cc66;">&#40;</span> var i:int = <span style="color: #cc66cc;">0</span>; i &lt; items.length; i++ <span style="color: #66cc66;">&#41;</span></span>
<span style="color: #000000;">                <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    trace<span style="color: #66cc66;">&#40;</span> items<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;">&lt;mx :Label text=<span style="color: #ff0000;">&quot;Welcome&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;">&lt;/mx<span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p><em>Note:<br />
AARG&#8230; i can&#8217;t find a decent mxml plugin for Wordpress. There is an errant closing</em> mx <em>tag before the script and the closing tag at the end should read</em> /mx:WindowedApplication . <em>If anyone has any tips on a good plugin, please leave a comment!</em></p>
<p>This assigns the <code>onAppInvoke()</code> method as the handler to the &#8216;invoke&#8217; event dispatched from <code>WindowedApplication</code> upon instantiation AND any subsequent invocation calls. The arguments attribute of the <code>InvokeEvent</code> is a list of strings &#8211; deliminated by space if you on the command line. From here, just handle them as you want to. In following with this example we are going to handle paths to simple text files.</p>
<p><strong>BindingUtils</strong><br />
All this filetypes and invoke events craziness is enough to warrent me to stop writing&#8230; but i got to thinking (always bad news)&#8230; what if i&#8217;ve got an &#8216;invoke&#8217; event that may trigger prior to the creation of a client that needs to know about an opened file, or more so, the app needs to switch focus to a client that has yet to be instantiated that knows how to handle that file? This is where <code>BindingUtils </code>and <code>ChangeWatcher </code>come into play and really show off the power of the Flex Framework.</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt; ?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;">&lt;mx :WindowedApplication </span>
<span style="color: #000000;">    xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">    layout=<span style="color: #ff0000;">&quot;vertical&quot;</span> </span>
<span style="color: #000000;">    horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #000000;">    applicationComplete=<span style="color: #ff0000;">&quot;onAppComplete();&quot;</span></span>
<span style="color: #000000;">    invoke=<span style="color: #ff0000;">&quot;onAppInvoke(event);&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;">&lt;/mx<span style="color: #7400FF;">&gt;</span>&lt;mx :Script<span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt; !<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            import mx.binding.utils.ChangeWatcher;</span>
<span style="color: #000000;">            import mx.binding.utils.BindingUtils;</span>
<span style="color: #000000;">            import mx.events.FlexEvent;</span>
&nbsp;
<span style="color: #000000;">            private var _invokedFile:File;</span>
<span style="color: #000000;">            private var _fileWindow:FileDisplayWindow;</span>
<span style="color: #000000;">            private var _filesBinding:ChangeWatcher;</span>
&nbsp;
<span style="color: #000000;">            private function onAppComplete<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:void</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                _filesBinding = BindingUtils.bindSetter<span style="color: #66cc66;">&#40;</span> invalidateFiles, this, <span style="color: #ff0000;">'invokedFile'</span>, true <span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            private function onAppInvoke<span style="color: #66cc66;">&#40;</span> evt:InvokeEvent <span style="color: #66cc66;">&#41;</span>:void</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                var items:Array = evt.arguments;</span>
<span style="color: #000000;">                if<span style="color: #66cc66;">&#40;</span> items.length <span style="color: #7400FF;">&gt;</span></span> 0 )
                {
                    invokedFile = new File( evt.arguments[0] );
                }    
            }
&nbsp;
            private function openFileWindow():void
            {
                _fileWindow = new FileDisplayWindow();
                _fileWindow.addEventListener( FlexEvent.CREATION_COMPLETE, applyFileToWindow );
                _fileWindow.open();
            }
&nbsp;
            private function applyFileToWindow( evt:FlexEvent = null ):void
            {
                _fileWindow.file = _invokedFile;
            }
&nbsp;
            private function invalidateFiles( arg:* = null ):void
            {
                if( _invokedFile == null ) return;
                if( _fileWindow == null || _fileWindow.closed ) openFileWindow();
                else applyFileToWindow();
            }
&nbsp;
            [Bindable]
            public function get invokedFile():File
            {
                return _invokedFile;
            }
            public function set invokedFile( arr:File ):void
            {
                _invokedFile = arr;
            }
&nbsp;
        ]]&gt;
    <span style="color: #000000;">&lt;mx :Label text=<span style="color: #ff0000;">&quot;Welcome&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;">&lt;/mx<span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p><em>Note:<br />
Again i apologize for the terrible representation of mxml code. To view the full code,</em> <a href="http://custardbelly.com/downloads/air/FileTypeFun" target="blank">click here</a></p>
<p>On dispatch of &#8216;applicationComplete&#8217;, a <code>ChangeWatcher </code>instance is created to bind any changes to the <code>invokeFile </code>attribute to the <code>invalidateFiles()</code> method. The <code>invalidateFiles()</code> method will be called upon a change to the <code>invokedFile </code>which is of type <code>File </code>from the AIR API. The client that handles any invoked files in this case is another addition to the AIR API &#8211; Window. I threw it in there because i can&#8217;t stop wanting to use it <img src='http://darko.liquidweb.com/~custardb/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The <code>invalidateFiles()</code> has checks to see if the file is valid as well as to make sure the <code>Window </code>is open and ready to receive data. Basically, with binding a change to the <code>invokedFile </code>attribute to the i<code>nvalidateFiles()</code> handler, we can be sure that when a file is requested to be open &#8211; either through invocation from the command, double-click, or &#8216;open with&#8217; &#8211; the <code>Window </code>client that knows how to handle that file data will be presented.</p>
<p>This just scratches the surface. There are icons you can associate with file types, there&#8217;s drag and drop capabilities that can update the invoked file if wanted&#8230; i just have to stop typing at some point!</p>
<p><a href="http://custardbelly.com/downloads/air/FileTypeFun" target="blank">View the full source code here.</a> I didn&#8217;t offer up the air app to download because it&#8217;s a rather boring app, but it is included in the source if you want to install it and test out the invocation.</p>
<p>If you made it this far and haven&#8217;t checked out <a href="http://labs.adobe.com/technologies/air/" target="_blank">AIR</a>, go <a href="http://labs.adobe.com/" target="_blank">download the bits</a>. And maybe consider buying <a href="http://www.amazon.com/Adobe-AIR-Create-Modify-Reuse/dp/0470182075/ref=pd_bbs_sr_6/002-5985048-8156021?ie=UTF8&#038;s=books&#038;qid=1191552882&#038;sr=8-6">a book</a> or <a href="http://amazon.com/s/ref=nb_ss_gw/102-6567738-0807350?initialSearch=1&#038;url=search-alias%3Daps&#038;field-keywords=Adobe+AIR&#038;Go.x=0&#038;Go.y=0&#038;Go=Go"> two</a>&#8230; <img src='http://darko.liquidweb.com/~custardb/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://custardbelly.com/blog/?feed=rss2&amp;p=62</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wrox AIR Instant Results book</title>
		<link>http://custardbelly.com/blog/?p=61</link>
		<comments>http://custardbelly.com/blog/?p=61#comments</comments>
		<pubDate>Fri, 03 Aug 2007 13:57:50 +0000</pubDate>
		<dc:creator>todd anderson</dc:creator>
				<category><![CDATA[Apollo]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://custardbelly.com/blog/?p=61</guid>
		<description><![CDATA[The cat&#8217;s outta the bag&#8230; and threw up on the middle of the cover. If for some insane reason you have been wondering about the lack of posts, i have been saving my mastery of the english language to co-author a book on AIR. 
I&#8217;ve been fortunate enough to work alongside Marc and Matt to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/AIR-Instant-Results-Marc-Luchner/dp/0470182075/ref=sr_1_1/105-9609728-7107659?ie=UTF8&#038;s=books&#038;qid=1186022411&#038;sr=8-1" target="_blank">The cat&#8217;s outta the bag</a>&#8230; and threw up on the middle of the cover. If for some insane reason you have been wondering about the lack of posts, i have been saving my mastery of the english language to co-author a book on <a href="http://labs.adobe.com/wiki/index.php/AIR" target="_blank">AIR</a>. </p>
<p>I&#8217;ve been fortunate enough to work alongside <a href="http://blog.nobien.net/" target="_blank">Marc and Matt</a> to produce a &#8216;by example&#8217; book on <a href="http://labs.adobe.com/wiki/index.php/AIR" target="_blank">AIR</a> that we hope people will enjoy reading as much as we have writing it. <a href="http://blog.nobien.net/2007/07/31/wrox-air-instant-results/" target="_blank">Matt took the words out of my mouth</a>, but with any new technology there is always the jazz of it&#8217;s potential and then the questioning of its practicality. I can say for certain, after having worked with it for the past several months, that <a href="http://labs.adobe.com/wiki/index.php/AIR" target="_blank">AIR</a> is the next generation in desktop software development.</p>
<p>The <a href="http://www.wrox.com/WileyCDA/" target="_blank">Wrox <em>Instant Results</em></a>  series walks you through building applications while learning the platform API, and this is no different. We have assembled a dozen examples that you can walk away from and use as well as expand upon. As the book progesses, you build on your knowledge from previous chapters and learn new aspects of the API. With a general knowledge of Flex and basic understanding of OOP, anyone can jump into this book and take off running with their own ideas.</p>
<p>Also available from Wiley Wrox is <a href="http://www.amazon.com/Professional-AIR-Application-Development-Integrated/dp/0470170212/ref=sr_1_6/105-9609728-7107659?ie=UTF8&#038;s=books&#038;qid=1186025851&#038;sr=1-6" target="_blank"><em>Professional AIR</em></a> by the esteemed <a href="http://www.chuckstar.com/blog/index.php/technology/announcing-wrox-professional-apollo-book/" target="_blank">Chuck Freedman</a>, mister <a href="http://bit-101.com/blog">Keith Peters</a>, Clint Modien, Ben Lucyk, and Ryan Manning.<br />
<a href="http://www.amazon.com/AIR-Instant-Results-Marc-Luchner/dp/0470182075/ref=sr_1_1/105-9609728-7107659?ie=UTF8&#038;s=books&#038;qid=1186022411&#038;sr=8-1"><br />
Wrox AIR Instant Results</a></p>
]]></content:encoded>
			<wfw:commentRss>http://custardbelly.com/blog/?feed=rss2&amp;p=61</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customizing the Apollo NativeWindow</title>
		<link>http://custardbelly.com/blog/?p=60</link>
		<comments>http://custardbelly.com/blog/?p=60#comments</comments>
		<pubDate>Fri, 06 Apr 2007 11:50:27 +0000</pubDate>
		<dc:creator>todd anderson</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Apollo]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://custardbelly.com/blog/?p=60</guid>
		<description><![CDATA[Daniel Dura wrote up a great post on adding Flex components to NativeWindows. If you are looking to add Flex components to your NativeWindow instance, you will need to follow what Daniel described.  As Daniel has mentioned, this is an issue concerning the alpha version of Apollo and may be cleared up in the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.danieldura.com/" target="_blank">Daniel Dura</a> wrote up a <a href="http://www.danieldura.com/archive/apollo-multi-window-support-using-flex"  target="_blank">great post</a> on adding Flex components to NativeWindows. If you are looking to add Flex components to your NativeWindow instance, you will need to follow what Daniel described.  As Daniel has mentioned, this is an issue concerning the <a href="http://www.adobe.com/go/apollo"  target="_blank">alpha version of Apollo</a> and may be cleared up in the next release, but if you can&#8217;t wait and are looking to add custom ActionScript components that extend Flex components, there is another option. </p>
<p>I don&#8217;t pretend to know enough about the architecture (so someone speak up if i am off track), but adding components to NativeWindows &#8211; without Daniel&#8217;s or the proceeding example- fails due to the reference to your main ApolloApplication&#8217;s stage when displaying components within the Flex framework. You can add all the displays existent in the AS3 library (Sprite, TextField, etc.) to the stage of your NativeWindow instance, but any in the Flex framework need a little push. Adding MXML components to your NativeWindows will still have to follow the formula Daniel laid out using the addChild/removeChild methods, yet there is a workaround to this for ActionScript components by adding an ADDED_TO_STAGE event listener within its constructor.</p>
<p>I have a tendency to try and word things right and it comes out all mush, so i&#8217;ll just show some code. <em>You can alternatively look at<a href="http://custardbelly.com/downloads/apollo/NativeWindowExample" target="_blank"> source view</a></em>. </p>
<p>The CustomLabel (CustomLabel.as) component that will be added to our NativeWindow:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">        <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
	<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextField</span>;
&nbsp;
	<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">containers</span>.<span style="color: #006600;">Canvas</span>;
&nbsp;
	<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CustomLabel <span style="color: #0066CC;">extends</span> Canvas
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _label:<span style="color: #0066CC;">TextField</span>;
&nbsp;
		<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> CustomLabel<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</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>;
			addEventListener<span style="color: #66cc66;">&#40;</span> Event.<span style="color: #006600;">ADDED_TO_STAGE</span>, init <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span> evt:Event <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
			createChildren<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> createChildren<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: #006600;">createChildren</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
			_label = createField<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;HelloWorld&quot;</span> <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> _label <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		override protected <span style="color: #000000; font-weight: bold;">function</span> updateDisplayList<span style="color: #66cc66;">&#40;</span> unscaledWidth:<span style="color: #0066CC;">Number</span>, unscaledHeight:<span style="color: #0066CC;">Number</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: #006600;">updateDisplayList</span><span style="color: #66cc66;">&#40;</span> unscaledWidth, unscaledHeight <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> createField<span style="color: #66cc66;">&#40;</span> txt:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">TextField</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">var</span> label:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
			label.<span style="color: #0066CC;">text</span> = txt;
			<span style="color: #b1b100;">return</span> label;	
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>&#8230; And the main mxml  (NativeWindowExample.mxml):</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;mx :ApolloApplication </span>
<span style="color: #000000;">	xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">	width=<span style="color: #ff0000;">&quot;200&quot;</span></span>
<span style="color: #000000;">	height=<span style="color: #ff0000;">&quot;100&quot;</span> </span>
<span style="color: #000000;">	layout=<span style="color: #ff0000;">&quot;absolute&quot;</span></span>
<span style="color: #000000;">	applicationComplete=<span style="color: #ff0000;">&quot;onAppInit();&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;">&lt;/mx<span style="color: #7400FF;">&gt;</span>&lt;mx :Script<span style="color: #7400FF;">&gt;</span></span>
		<span style="color: #000000;">&lt; !<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
&nbsp;
<span style="color: #000000;">			private var _launchWindow:NativeWindow;</span>
<span style="color: #000000;">			private var _customWindow:NativeWindow;</span>
&nbsp;
<span style="color: #000000;">			private function onAppInit<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:void</span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">				_launchWindow = this.stage.window;</span>
<span style="color: #000000;">				_launchWindow.addEventListener<span style="color: #66cc66;">&#40;</span> Event.CLOSE, onAppClose <span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">			private function openCustomWindow<span style="color: #66cc66;">&#40;</span> evt:MouseEvent <span style="color: #66cc66;">&#41;</span>:void</span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">				if<span style="color: #66cc66;">&#40;</span> _customWindow != null <span style="color: #66cc66;">&#41;</span> return;</span>
&nbsp;
<span style="color: #000000;">				var options:NativeWindowInitOptions = new NativeWindowInitOptions<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">				_customWindow = new NativeWindow<span style="color: #66cc66;">&#40;</span> true, options <span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">				_customWindow.stage.align = StageAlign.TOP_LEFT;</span>
<span style="color: #000000;">				_customWindow.stage.scaleMode = StageScaleMode.NO_SCALE;</span>
<span style="color: #000000;">				_customWindow.title = <span style="color: #ff0000;">&quot;CustomWindow&quot;</span>;</span>
<span style="color: #000000;">				_customWindow.stage.addChild<span style="color: #66cc66;">&#40;</span> new CustomLabel<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">				_customWindow.addEventListener<span style="color: #66cc66;">&#40;</span> Event.CLOSE, onWindowClose <span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">			private function onWindowClose<span style="color: #66cc66;">&#40;</span> evt:Event <span style="color: #66cc66;">&#41;</span>:void</span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">				_customWindow = null;</span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">			private function onAppClose<span style="color: #66cc66;">&#40;</span> evt:Event <span style="color: #66cc66;">&#41;</span>:void</span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">				if<span style="color: #66cc66;">&#40;</span> _customWindow != null <span style="color: #66cc66;">&#41;</span> _customWindow.close<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">			<span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">		<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;">&lt;/mx<span style="color: #7400FF;">&gt;</span></span>
&nbsp;
	<span style="color: #000000;">&lt;mx :Button id=<span style="color: #ff0000;">&quot;windowBtn&quot;</span> </span>
<span style="color: #000000;">		top=<span style="color: #ff0000;">&quot;10&quot;</span> left=<span style="color: #ff0000;">&quot;10&quot;</span> right=<span style="color: #ff0000;">&quot;10&quot;</span> bottom=<span style="color: #ff0000;">&quot;10&quot;</span></span>
<span style="color: #000000;">		label=<span style="color: #ff0000;">&quot;open custom window&quot;</span></span>
<span style="color: #000000;">		click=<span style="color: #ff0000;">&quot;openCustomWindow( event );&quot;</span><span style="color: #7400FF;">&gt;</span></span>
	<span style="color: #000000;">&lt;/mx<span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p><strong>NOTE:</strong> <em>the preceding code has some major problems due to mx tags in wordpress, so disregard all affending close tags <img src='http://darko.liquidweb.com/~custardb/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em></p>
<p> &#8212; As well, you could extend NativeWindow and add the AS components to its stage to bypass adding them in the main app. &#8211;</p>
<p>In the main app file we are just creating a new NativeWindow instance and adding the custom AS component, CustomLabel, to it&#8217;s display.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">_customWindow.<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> CustomLabel<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>What is happening in the constructor of the CustomLabel is of importance in this example, as it listens for its event of being added to a clients stage. From there we can call the override of UIComponent:createChildren, and add whatever we want to the display. When creating AS components NOT to be added to the NativeWindow, that method (createChildren) would be called as long as you call the super constructor. That is not the case when adding components extending the Flex framework in NativeWindow. Again, if i am missing something crucial or if you have more insight, please leave a comment. So that&#8217;s it. Once it has been added to the stage, we can go about our business. Of course, when using ActionScript components you lose the inherent layout capabilities within MXML components, but that is why we&#8217;ve added the override of #updateDisplayList.<br />
Until Flex came around, i know i spent more than my fair share nailing down layouts for applications- so this is like going back home&#8230; <img src='http://darko.liquidweb.com/~custardb/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>To find out more about extending ActionScript components, visit<a href="http://blog.flashgen.com/2006/11/08/base-component-methods-actionscript-20-to-30/"  target="_blank"> this post</a> on FlashGen and <a href="http://download.macromedia.com/pub/documentation/en/flex/2/flex2_createextendcomponents.pdf"  target="_blank">this doc</a> from <a href="http://labs.adobe.com/">the labs</a>.</p>
<p>PS. I&#8217;ve been a little lacking in the post area, and though i have the usual excuses- family, work, beer&#8230; &#8211; i could be more on top of it and you should be seeing more Flex and Apollo thoughts in the near future, but no promises because i love those excuses. I also am working on something that i hope to announce here a little later if all goes well&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://custardbelly.com/blog/?feed=rss2&amp;p=60</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
