<?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>lowpitch.com &#187; Flex Builder</title>
	<atom:link href="http://lowpitch.com/blog/category/flex-builder/feed/" rel="self" type="application/rss+xml" />
	<link>http://lowpitch.com/blog</link>
	<description>Flex and flex ramblings.</description>
	<lastBuildDate>Sun, 24 Aug 2008 22:57:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating AIR projects with Actionscript</title>
		<link>http://lowpitch.com/blog/creating-air-projects-with-actionscript/</link>
		<comments>http://lowpitch.com/blog/creating-air-projects-with-actionscript/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 18:54:53 +0000</pubDate>
		<dc:creator>lowpitch</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Flex Builder]]></category>
		<category><![CDATA[AS 3.0]]></category>

		<guid isPermaLink="false">http://lowpitch.com/blog/?p=7</guid>
		<description><![CDATA[If you&#8217;re using Flex Builder 3, and you want to create an Actionscript project which will eventually deploy as an AIR application, you&#8217;ll quickly find that this option isn&#8217;t available when using the Actionscript Project Wizard. There are plenty of posts out there detailing a workaround (for example, see here).
I followed the workaround steps and [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using Flex Builder 3, and you want to create an Actionscript project which will eventually deploy as an AIR application, you&#8217;ll quickly find that this option isn&#8217;t available when using the Actionscript Project Wizard. There are plenty of posts out there detailing a workaround (for example, see <a href="http://www.digitalflipbook.com/archives/2007/10/air_application.php" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.digitalflipbook.com');" target="_blank">here</a>).</p>
<p>I followed the workaround steps and it seemed to work OK, but when I first published my application&#8230; nothing happened. A little icon appeared in my dock, mysteriously titled <em>adl </em>(which I&#8217;ve since discovered stands for the <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=CommandLineTools_4.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/livedocs.adobe.com');" target="_blank">AIR debug launcher</a>), but no windows of Flash-based goodness appeared anywhere. After much digging around, I came across <a href="http://bugs.adobe.com/jira/browse/FB-9303" onclick="javascript:pageTracker._trackPageview('/outbound/article/bugs.adobe.com');" target="_blank">this entry in the Adobe Bug System</a> and found the answer buried away in the comments.</p>
<p>When I&#8217;d previously created Flex-based AIR projects, I hadn&#8217;t really appreciated that the Flex framework was handling all of the window-creating shenanigans on my behalf. Just by making my root MXML tag a <em>WindowedApplication</em>, instead of a &#8220;normal&#8221; <em>Application</em>, the main AIR window was being created and activated automatically. When you&#8217;re not using the Flex framework, you have to do this stuff yourself.</p>
<p>As it turns out, the two most important classes involved in this process are <a href="http://livedocs.adobe.com/flex/3/langref/flash/display/NativeWindow.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/livedocs.adobe.com');" target="_blank"><em>flash.display.NativeWindow</em></a> and <a href="http://livedocs.adobe.com/flex/3/langref/flash/display/NativeWindowInitOptions.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/livedocs.adobe.com');" target="_blank"><em>flash.display.NativeWindowInitOptions</em></a>. A <em>NativeWindow </em>is essentially the window you see on your desktop when you run an AIR application. This includes the menu bar (if any) and the system chrome (if any).</p>
<p>To successfully create and launch a window in AIR, you&#8217;ll need to create and activate a NativeWindow object, and then add your Document class (or some Sprite, at least) to that Window&#8217;s stage, accessible through the NativeWindow&#8217;s <em>stage </em>property. The code will look something like&#8230;</p>
<div class="codecolorer-container actionscript"><div class="codecolorer" style="font-family: monospace;"><span class="co1">// create an instance of NativeWindowInitOptions to pass to the NativeWindow constructor</span><br />
<span class="kw2">var</span> windowOptions:NativeWindowInitOptions = <span class="kw2">new</span> NativeWindowInitOptions<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="co1">// create the window</span><br />
<span class="kw2">var</span> mainWindow:NativeWindow = <span class="kw2">new</span> NativeWindow<span class="br0">&#40;</span>windowOptions<span class="br0">&#41;</span>;<br />
<span class="co1">// activate the window</span><br />
mainWindow.<span class="me1">activate</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="co1">// adds &quot;this&quot; to the stage of the Window we have created</span><br />
mainWindow.<span class="kw3">stage</span>.<span class="me1">addChild</span><span class="br0">&#40;</span><span class="kw3">this</span><span class="br0">&#41;</span>;</div></div>
<p>This code will create and activate an AIR window with default options, and add <em>someSprite</em> to the stage of that Window. From then on, you can continue with your code just as you would in a traditional Flash application and all will work as expected. </p>
<p>I&#8217;ll post more about the <em>NativeWindow</em> and <em>NativeWindowInitOptions</em> classes at some point soon&#8230;.</p>
<p><em>(Update: <a href="http://lowpitch.com/blog/2008/08/07/nativewindowinitoptions-configure-your-air-nativewindow/" >Check out this post for more information about the NativeWindowInitOptions class</a>)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://lowpitch.com/blog/creating-air-projects-with-actionscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
