<?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; AIR</title>
	<atom:link href="http://lowpitch.com/blog/category/air/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>NativeWindow &#8211; using AIR windows with Actionscript (part 3 of 3)</title>
		<link>http://lowpitch.com/blog/nativewindow-using-air-windows-with-actionscript-part-3-of-3/</link>
		<comments>http://lowpitch.com/blog/nativewindow-using-air-windows-with-actionscript-part-3-of-3/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 14:58:35 +0000</pubDate>
		<dc:creator>lowpitch</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AS 3.0]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://lowpitch.com/blog/?p=17</guid>
		<description><![CDATA[In the first part of this post I covered each public property exposed by an instance of NativeWindow, before continuing to look at each public method in part two. In this final part of the series I&#8217;ll go through each of the different events dispatched by a NativeWindow during its lifetime.
Event.ACTIVATE
This event is sent out [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="/blog/2008/08/09/nativewindow-working-with-air-windows-with-actionscript-part-1-of-3/">first part of this post I covered each public property exposed by an instance of <em>NativeWindow</em></a>, before <a href="/blog/2008/08/10/nativewindow-using-air-windows-with-actionscript-part-2-of-3/">continuing to look at each public method in part two</a>. In this final part of the series I&#8217;ll go through each of the different events dispatched by a <em>NativeWindow</em> during its lifetime.</p>
<h3>Event.ACTIVATE</h3>
<p>This event is sent out when the window is activated. The event doesn&#8217;t go through a capture phase, and it won&#8217;t bubble up the Display List. Some examples of when your window may dispatch this event include:</p>
<ul>
<li>When the <em>NativeWindow </em>is first created and activated</li>
<li>When your application contains multiple <em>NativeWindows</em> and the user clicks on a window which previously was not the active window, giving it focus and bringing it to the front, the window will dispatch<em> Event.ACTIVATE</em></li>
<li>When you switch to another running application elsewhere on the system (an AIR application, or otherwise) and then switch back to this window, the event will be dispatched</li>
</ul>
<p><span id="more-17"></span></p>
<h3>Event.DEACTIVATE</h3>
<p>Similarly, this event is sent out when the window is deactivated. Again, the event doesn&#8217;t go through a capture phase, and it won&#8217;t bubble up the Display List. Some examples of when your window may dispatch this event include:</p>
<ul>
<li>When your application contains multiple <em>NativeWindows</em> and the user clicks on a window which previously was not the active window, giving it focus and bringing it to the front, the window which previously was active and had the focus will dispatch<em> Event.DEACTIVATE</em></li>
<li>When you switch to another running application elsewhere on the system (an AIR application, or otherwise), the previously active window will dispatch this event</li>
</ul>
<h3>Event.CLOSING<br />
Event.CLOSE</h3>
<p>I have grouped these two events as they are rather obviously connected. If the user clicks the exit button in the system chrome, for example, the sequence of events will be:</p>
<ul>
<li>An<em> Event.CLOSING</em> event is dispatched.</li>
<li>If this event is not cancelled (by calling the event&#8217;s <em>preventDefault</em> method) then the window will be closed, using <em>NativeWindow.close ()</em> which was discussed in the previous part of this post</li>
<li>Once the window has been closed, an <em>Event.CLOSE </em>event will be dispatched</li>
</ul>
<p>As mentioned in the previous part of this series, if you want to implement your own &#8220;close&#8221; functionality, perhaps by creating your own application chrome, you should follow this same logic to give other objects elsewhere in your application a chance to cancel the closing operation if necessary.</p>
<h3>NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING<br />
NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE</h3>
<p>Again, these events are related in a similar way to <em>Event.CLOSING </em>and <em>Event.CLOSE</em>. The events are dispatched as part of one of the following operations:</p>
<ul>
<li>Maximizing a window which was previously un-maximized</li>
<li>Minimizing a window which was previously un-minimized</li>
<li>Restoring a window from a maximized or minimized state</li>
</ul>
<p>Unlike <em>Event.CLOSING</em> / <em>Event.CLOSE</em>, these events are defined within a subclass of <em>Event</em>, suggesting that there may be some added goodies within the event object that we can examine. As expected, there are a couple of properties available to tell us a little more about what is happening &#8211; to be more precise, the event object will tell us the value of the current state, and the value of the state we are moving to.</p>
<p>This is information is available by examining the <em>NativeWindowDisplayStateEvent.beforeDisplayState</em> and <em>NativeWindowDisplayStateEvent.afterDisplayState</em> properties. Both properties will be a string, matching one of the constants defined in the <em>NativeWindowDisplayState</em> class. These are:</p>
<ul>
<li><em>NativeWindowDisplayState.MAXIMIZED</em></li>
<li><em>NativeWindowDisplayState.MINIMIZED</em></li>
<li><em>NativeWindowDisplayState.NORMAL</em></li>
</ul>
<p>So, for example, when a user clicks the maximize button in the system chrome, the sequence of events will be:</p>
<ul>
<li>A<em> </em><em>NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING </em> event is dispatched.</li>
<li>If this event is not cancelled (by calling the event&#8217;s <em>preventDefault</em> method) then the state change will continue</li>
<li>Once the display state has updated, a <em>NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE </em><em></em>event will be dispatched</li>
</ul>
<h3>NativeWindowBoundsEvent.MOVING<br />
NativeWindowBoundsEvent.MOVE</h3>
<p>These events are dispatched whenever the position of the window within the system desktop is moved. This could be for one of a number of reasons:</p>
<ul>
<li>A system-controlled move operation, for example the user dragging the window around with the system chrome</li>
<li>If the window is maximized</li>
<li>If the window is minimized</li>
<li>If the window is restored from maximized, or minimized state</li>
<li>If the window is moved programmatically, by setting the <em>x</em>, <em>y</em>, or <em>bounds </em>properties</li>
</ul>
<p>Again, the events here are defined in a custom subclass of <em>Event</em>, and this time the hidden treasures available to use are the <em>beforeBounds </em>and <em>afterBounds </em>properties, which obviously tell the us the &#8220;old&#8221; and &#8220;new&#8221; positions (and sizes, if we&#8217;re interested) of the window.</p>
<p>The sequence of events which would happen as part of a move operation would be:</p>
<ul>
<li>A<em> </em><em>NativeWindowBoundsEvent.MOVING</em> event is dispatched.</li>
<li>If this event is not cancelled (by calling the event&#8217;s <em>preventDefault</em> method) then the move operation will continue</li>
<li>Once the window has been moved, a <em>NativeWindowBoundsEvent.MOVE </em>event will be dispatched</li>
</ul>
<p>It&#8217;s worth noting that when a window is being dragged around by the user, it will repeatedly go through this cycle, moving the window in small steps. If at any stage, one of the <em>NativeWindowBoundsEvent.MOVING </em>events is cancelled, the move operation will terminate. This includes moves triggered by the <em>NativeWindow.startMove () </em>method discussed in the previous part of the post.</p>
<h3>NativeWindowBoundsEvent.RESIZING<br />
NativeWindowBoundsEvent.RESIZE</h3>
<p>The events listed here work similarly to those dispatched as part of the move operation, although this time they apply to resize operations. Resize operations may occur for one of a number of reasons:</p>
<ul>
<li>A system-controlled resize operation, for example the user resizing the window via the system resize handles</li>
<li>If the window is maximized</li>
<li>If the window is minimised</li>
<li>If the window is restored from maximized, or minimized state</li>
<li>If the window is resized programmatically, by setting the <em>width</em>, <em>height</em> or <em>bounds </em>properties</li>
</ul>
<p>The event type is the same as with the move operation, giving us access to the &#8220;old&#8221; and &#8220;new&#8221; sizes of the window. The sequence of events works in the same way too:</p>
<ul>
<li>A<em> </em><em>NativeWindowBoundsEvent.RESIZING</em> event is dispatched.</li>
<li>If this event is not cancelled (by calling the event&#8217;s <em>preventDefault</em> method) then the resize operation will continue</li>
<li>Once the window has been resized, a <em>NativeWindowBoundsEvent.RESIZE </em>event will be dispatched</li>
</ul>
<p>Lastly, as with the move operation, when a window is being resized by the user, it will repeatedly go through this cycle, resizing the window in small steps. If at any stage, one of the <em>NativeWindowBoundsEvent.RESIZING </em>events is cancelled, the resize operation will terminate. This includes resizes triggered by the <em>NativeWindow.startResize () </em>method discussed in the previous part of the post.</p>
<h3>That&#8217;s all of &#8216;em</h3>
<p>So that&#8217;s all of the events covered now. You can see how to handle various different operations that will happen during the lifetime of your window. You can react to (and cancel, if you wish) moves, resizes and the closing of your window. Most importantly, if creating your own application chrome, or implementing your own close/resize/move functionality, you should try and keep these operations cancelable. It&#8217;ll make things much easier down the line if, for example, you want to stop the user closing the window before the save their work.</p>
<h3>Conclusion</h3>
<p>I&#8217;ve now gone through all of the properties, methods and events exposed by a <em>NativeWindow</em>. As you can see, the API is fairly thorough, but extremely simple to use. It makes it easy to create, move, resize, hide, and reorder your windows, and to control how your windows will look and behave. I will try and carry this all through into an example at some point, but for now I hope this explanation has been fairly useful. Gimme a shout if there&#8217;s anything I&#8217;ve missed&#8230;&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://lowpitch.com/blog/nativewindow-using-air-windows-with-actionscript-part-3-of-3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>NativeWindow &#8211; using AIR windows with Actionscript (part 2 of 3)</title>
		<link>http://lowpitch.com/blog/nativewindow-using-air-windows-with-actionscript-part-2-of-3/</link>
		<comments>http://lowpitch.com/blog/nativewindow-using-air-windows-with-actionscript-part-2-of-3/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 00:10:13 +0000</pubDate>
		<dc:creator>lowpitch</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AS 3.0]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://lowpitch.com/blog/?p=16</guid>
		<description><![CDATA[In the previous post I listed the public properties exposed by an instance of NativeWindow. In this post, I&#8217;ll be going through NativeWindow&#8217;s public methods. The third and final part of this series will explain the Events dispatched by a NativeWindow during its lifetime.
Once a NativeWindow has been created, you can call methods to move, [...]]]></description>
			<content:encoded><![CDATA[<p>In the previous post I listed the <a href="/blog/2008/08/09/nativewindow-working-with-air-windows-with-actionscript-part-1-of-3/">public properties exposed by an instance of <em>NativeWindow</em></a>. In this post, I&#8217;ll be going through <em>NativeWindow&#8217;</em>s public methods. The third and final part of this series will explain the Events dispatched by a <em>NativeWindow </em>during its lifetime.</p>
<p>Once a <em>NativeWindow</em> has been created, you can call methods to move, resize, reposition, activate and close the window. All these methods are fairly simple, with the odd gotcha thrown in for good measure. So, here&#8217;s a description of each of these methods&#8230;</p>
<p><span id="more-16"></span></p>
<h3><strong>NativeWindow.activate ()</strong></h3>
<p>Calling <em>NativeWindow.activate () </em>firstly sets the <em>visible </em>of the window to <em>true</em>. Next, the window is brought to the front. Lastly, the window is given keyboard and mouse focus. Typically, you&#8217;d call the <em>activate </em>method shortly after creating it.</p>
<h3>NativeWindow.close ()</h3>
<p>This method, rather obviously, closes the window. This has several implications&#8230; First of all, once a window has been closed, it cannot be re-opened. References to a window that has been closed will exist, but some methods and properties of that window will no longer be available, and if accessed an exception will be thrown. Any DisplayObjects that were within the window, and not referenced anywhere else, will be available for Garbage Collection.</p>
<p>If you just want to close a window temporarily, consider setting its <em>visible </em>to false.</p>
<p>One other thing to mention here&#8230; when you call <em>NativeWindow.close () </em>no event is dispatched to signify the window is about to close. A Close event is sent out after the window has been closed, but if you want the action of closing the window to be preventable, you&#8217;ll need to send out a Closing event (take a look at <em>air.Event.CLOSING</em> which is more than suitable) giving interested parties a chance to set <em>preventDefault </em>on that event. If , and only if, the isDefaultPrevented () method of your custom Closing event returns <em>false</em>, then you can proceed to close your window.</p>
<h3>NativeWindow.globalToScreen (globalPoint:Point)</h3>
<p>This method is kind of like MovieClip.localToGlobal from days gone by, but takes things one step further. The method takes a Point object, representing co-ordinates relative to the origin of the <em>NativeWindow</em>&#8217;s stage and converts it to a Point object representing the same position relative to the top-left position of the system&#8217;s desktop.</p>
<h3>NativeWindow.maximize ()<br />
NativeWindow.minimize ()<br />
NativeWindow.restore ()</h3>
<p>This three methods are kind of similar, so I&#8217;ve grouped them here. The methods will attempt to maximize, minimize or restore the <em>NativeWindow</em> programmatically.</p>
<p>All three operations happen asynchronously, and you can detect the completion of these operations by listening out for a <em>NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE </em>event.</p>
<p>Something important to note here, when the user tries to perform one of these three actions from the system chrome, a <em>NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING</em> event is dispatched, giving interested parties a chance to cancel the operation (by calling <em>preventDefault</em> <em>() </em>). To ensure this behaviour is also preventable when performing these options with code, you&#8217;ll need to manually dispatch a suitable <em>DISPLAY_STATE_CHANGING </em>event, and then investigate the event&#8217;s <em>isDefaultPrevented () </em>method before continuing the maximize / minimize / restore operation.</p>
<h3>NativeWindow.notifyUser (type:String)</h3>
<p>Assuming that <em>NativeWindow.supportsNotification </em>is <em>true </em>(see the previous post for more details), calling this method will trigger a visual cue to the user that something has happened. There are currently two different types of cue that you can trigger.<em> NotificationType.INFORMATIONAL</em> will trigger the cue for a short period of time, whereas <em>NotificationType.CRITICAL</em> will ensure the visial cue continues until the user brings focus to the window.</p>
<h3>NativeWindow.orderInBackOf (window:NativeWindow)<br />
NativeWindow.orderInFrontOf (window:NativeWindow)</h3>
<p>These methods will move the window directly behind, or in front of, the window passed as the parameter. As always, some things to note.</p>
<ul>
<li>Attempting to re-order minimized or hidden windows is not possible.</li>
<li>The methods will return true if the window was moved successfully, and false otherwise.</li>
<li>If the window that you are moving behind, or in front of, has a different <em>alwaysInFront</em> property than the current window (<a href="/blog/2008/08/09/nativewindow-working-with-air-windows-with-actionscript-part-1-of-3/">see the previous post for more information</a>), the window you are moving will have its <em>alwaysInFront </em>property changed to match this other window.</li>
<li>When a window is reordered, it is not activated, and is not given the focus.</li>
</ul>
<h3>NativeWindow.orderToBack ()<br />
NativeWindow.orderToFront ()</h3>
<p>These methods will move the window behind, or in front of, all other visible windows. Things to note here include:</p>
<ul>
<li>Attempting to re-order minimized or hidden windows is not possible.</li>
<li>The methods will return true if the window was moved successfully, and false otherwise.</li>
<li>If the window&#8217;s <em>alwaysInFront </em>property is set to <em>false, </em>then calling <em>orderToFront</em> () will not move the window in front of any windows which have <em>alwaysInFront </em>set to <em>true.</em></li>
<li>Likewise, if the window&#8217;s <em>alwaysInFront </em>property is set to <em>true </em>then calling <em>orderToBack () </em>will not move the window behind any windows which have <em>alwaysInFront </em>set to <em>false</em>.</li>
</ul>
<h3>NativeWindow.startMove ()</h3>
<p>Calling this method will trigger the start of a system-controlled move of the window. What this means is that you can create your own custom drag bar, listen to <em>MouseEvent.MOUSE_DOWN</em> events from that drag bar and then, in the event handler, call <em>myNativeWindow.startMove () </em>to begin the move process.</p>
<p>While the window is being moved, the window dispatches various events. This will be covered in more detail in the next part of this discussion. However, it&#8217;s worth mentioning here that a Move sequence can be terminated by handling, and then cancelling, the NativeWindowBoundsEvent.MOVING event.</p>
<p>The method returns <em>true</em> if the move process was successfully initiated, or <em>false</em> otherwise (for example, if the window was already maximized).</p>
<h3>NativeWindow.startResize (edgeOrCorner:String)</h3>
<p>This method is very similar to <em>NativeWindow.startMove (). </em>It allows you to create your own resize handles, listen to MouseMove.MOUSE_DOWN events from that resize handle, and then call myNativeWindow.startResize () from the event handler to begin the resize.</p>
<p>Again, while the window is being resized, it dispatches various events which will be covered in the next part of this discussion. As with moving a window, you can terminate the resize sequence by handling, then cancelling, the NativeWindowBoundsEvent.RESIZING event.</p>
<p>The method returns <em>true</em> if the resize process was successfully initiated, or <em>false</em> otherwise (for example, if the window was already maximized).</p>
<p>Unlike the <em>startMove </em>method, this method accepts a parameter. This parameter specifies which corner or edge of the window the resize should stem from. The possible values of this parameter are specified as constants in the <em>NativeWindowResize</em> class. The default is <em>NativeWindowResize.BOTTOM_RIGHT.</em></p>
<h3>That&#8217;s it!</h3>
<p>That&#8217;s all of the public methods exposed by the <em>NativeWindow</em> class. You can see how to move, resize and re-order windows within the operating system, how to visually alert the user that the application needs their attention, how to activate the window, and how to close it. In the final part of this topic I&#8217;ll describe the various different Events that are dispatched by a <em>NativeWindow</em> during it&#8217;s lifetime.</p>
<p>Update: Part 3 of this post <a href="/blog/2008/08/10/nativewindow-using-air-windows-with-actionscript-part-3-of-3/">can be found here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lowpitch.com/blog/nativewindow-using-air-windows-with-actionscript-part-2-of-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NativeWindow &#8211; using AIR windows with Actionscript (part 1 of 3)</title>
		<link>http://lowpitch.com/blog/nativewindow-working-with-air-windows-with-actionscript-part-1-of-3/</link>
		<comments>http://lowpitch.com/blog/nativewindow-working-with-air-windows-with-actionscript-part-1-of-3/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 18:06:56 +0000</pubDate>
		<dc:creator>lowpitch</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AS 3.0]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://lowpitch.com/blog/?p=12</guid>
		<description><![CDATA[In a previous post I described how to create and activate an application window when creating an Actionscript AIR project in Flex Builder 3. I then went on to describe in a little more detail the various properties of the NativeWindowInitOptions class, and how setting some or all of these properties can affect the style [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous post I described how to <a href="/blog/2008/08/04/creating-air-projects-with-actionscript/">create and activate an application window when creating an Actionscript AIR project in Flex Builder 3</a>. I then went on to describe in a little more detail the various <a href="/blog/2008/08/06/nativewindowinitoptions-configure-your-air-nativewindow/">properties of the NativeWindowInitOptions class</a>, and how setting some or all of these properties can affect the style and behaviour of the window that will be created. I guess the final step is to describe how to work with the window once it has been created, starting with an explanation of the <em>flash.display.NativeWindow</em> class. There&#8217;s quite a bit of functionality contained within the class, so I&#8217;ll break this post up into three. Part 1 will describe the properties of a NativeWindow, part 2 will list the public methods and finally part 3 will discuss the events dispatched by the Window throughout its lifetime.</p>
<p>As previously mentioned, an application window is created and displayed in Adobe AIR by creating a new instance of the <em>NativeWindow </em>class, and then calling this instance&#8217;s <em>activate</em> method. Content is added to the window by adding <em>DisplayObject</em>s to the <em>stage</em> property of the <em>NativeWindow</em> instance.</p>
<p>Here are descriptions of each of the <em>NativeWindow</em>&#8217;s public properties&#8230;</p>
<p><span id="more-12"></span></p>
<h3>NativeWindow.active</h3>
<p>Indicates whether or not a <em>NativeWindow</em> is the active application window or not. So for example, if your application has opened two windows, depending on which of those windows is currently being interacted with, one window&#8217;s <em>active </em>property will return <em>true, </em>and the other will return <em>false. </em> To activate a NativeWindow programmatically, you can call <em>someNativeWindow.activate ()</em>.</p>
<h3>NativeWindow.alwaysInFront</h3>
<p>Rather obviously, this Boolean property will specify whether or not the window will always be on top of other windows (even those from other applications). For most situations, this property should be left as <em>false </em>unless the window needs to stay on top of other applications for a particular reason.</p>
<p>It&#8217;s possible to trigger certain behaviours by changing the value of this property. Setting this value from <em>false </em>to <em>true </em>will bring the window in front of all other application windows. Changing the value from <em>true </em>to <em>false </em>will send the window behind any other windows on the system with <em>alwaysInFront </em>set to <em>true</em>, but still on top of all other windows.</p>
<h3>NativeWindow.bounds</h3>
<p style="text-align: left;">This property, of type <em>flash.geom.Rectangle, </em>contains information about the position and size of the window <strong>including any system chrome</strong>. The fact that these dimensions include the system chrome is important. The size of the stage of the window (the area which is used for any content added to the stage), is equal to the size of the window minus the size of the chrome.</p>
<p style="text-align: left;">Setting the <em>bounds </em>property of a window is the same as setting it&#8217;s <em>x</em>, <em>y</em>, <em>width</em>, and <em>height</em> properties all in one step.</p>
<p style="text-align: left;">If you attempt to set the size of the window to an illegal size (for example, smaller than the <em>minSize</em><strong> </strong>property, larger than the <em>maxSize</em> property, or larger or smaller than the limits imposed by the OS) then the window will be sized to the nearest acceptable value. This applies when setting the size of the window through the <em>bounds</em> property, and also when setting the <em>width </em>or <em>height </em>directly.</p>
<p style="text-align: left;">This property will be revisited in part 3 of this post when Events dispatched by the window will be discussed.</p>
<h3>NativeWindow.closed</h3>
<p style="text-align: left;">This Boolean indicates whether or not the window has been closed. Attempting to access certain properties or methods of a window which has been closed will cause an<em> IllegalOperationError</em> to be the thrown.</p>
<h3>NativeWindow.displayState</h3>
<p style="text-align: left;">This property is a string, and describes the window&#8217;s current display state. The possible values of this property are fairly self explanatory:</p>
<ul>
<li><em>NativeWindowDisplayState.NORMAL</em></li>
<li><em>NativeWindowDisplayState.MINIMIZED</em></li>
<li><em>NativeWindowDisplayState.MAXIMIZED</em></li>
</ul>
<h3>NativeWindow.height</h3>
<p>The height of the window <strong>including </strong>any system chrome. To access the height of the usable area within the system chrome, use <em>stage.stageHeight</em>.</p>
<h3>NativeWindow.maximizable</h3>
<p>This Boolean tells us whether or not the window is maximizable. The value is set using the NativeWindowInitOptions instance, passed to the constructor, and cannot be modified once the window has been created.</p>
<h3>NativeWindow.maxSize</h3>
<p>This property, of type <em>flash.geom.Point</em> (<em>Point.x</em> corresponds to the <em>width</em>, <em>Point.y</em> corresponds to the <em>height</em>), allows us to specify the maximum size of the window. This maximum size is enforced when resizing is triggered both by Actionscript, or by the user clicking the OS maximize button.</p>
<h3>NativeWindow.menu</h3>
<p>This property allows us to create a <em>flash.display.NativeMenu </em>to be displayed for the Window. Note, for the <em>menu </em>to be displayed, <em>NativeWindow.supportsMenu </em>must be set to <em>true</em>, and <em>NativeWindow.systemChrome</em> must not be set to <em>NativeWindowSystemChrome.NONE</em>.</p>
<h3>NativeWindow.minimizable</h3>
<p>This Boolean tells us whether or not the window is minimizable. The value is set using the NativeWindowInitOptions instance, passed to the constructor, and cannot be modified once the window has been created.</p>
<h3>NativeWindow.minSize</h3>
<p>This property, of type <em>flash.geom.Point</em>, allows us to specify the minimum size of the window. This minimum size is enforced when resizing is triggered either by Actionscript, or by the user clicking the OS maximize button.</p>
<h3>NativeWindow.resizable</h3>
<p>This Boolean tells us whether or not the window is resizable. The value is set using the NativeWindowInitOptions instance, passed to the constructor, and cannot be modified once the window has been created.</p>
<h3>NativeWindow.stage</h3>
<p>This property gives us <strong>read-only </strong>access to the <em>flash.display.Stage </em>object at the root of this window&#8217;s display list. For content to be displayed in the window, it must be added to the <em>stage</em> (or to a descendant of a <em>DisplayObject </em>already added to the stage).</p>
<h3>NativeWindow.supportsMenu</h3>
<p>Setting this Boolean to <em>true</em> allows us to display a <em>NativeMenu </em>for this window by setting the <em>menu </em>property (see above). For the menu to be displayed, the <em>systemChrome </em>property must not be set to <em>NativeWindowSystemChrome.NONE</em>.</p>
<h3>NativeWindow.supportsNotification</h3>
<p>You know how sometimes an application can flash in some way to show you that something has happened? On Windows, the window&#8217;s entry in the task bar might flash, or on OS X the icon in the dock might jump around a bit. This property tells you whether or not this functionality is supported on the system on which your application is running. If this property is <em>true</em>, you can trigger this visual cue with the window&#8217;s <em>notifyUser</em> method.</p>
<h3>NativeWindow.supportsTransparency</h3>
<p>This Boolean property tells us whether or not transparency of windows is supported in the current environment. If the <em>transparent </em>property of the window is set to <em>true</em>, and <em>supportsTransparency </em>is also <em>true</em>, then your transparent window will work as expected. If, however, <em>supportsTransparency </em>is <em>false</em>, the your transparent window will not render correctly. Any pixels intended to have an <em>alpha </em>of 0 will be rendered as black. It&#8217;s also worth noting that this value may change during the lifetime of your window, for example if a user updates a preference setting.</p>
<h3>NativeWindow.systemChrome</h3>
<p>This read-only property tells us what system chrome is employed by the window. The property will match one of the constants defined in the<em> NativeWindowSystemChrome</em> class. The <em>systemChrome</em> is originally specified in the <em>NativeWindowInitOptions</em> class which is passed to the <em>NativeWindow</em> constructor and <strong>cannot </strong>be altered once the window has been created.</p>
<h3>NativeWindow.systemMaxSize</h3>
<p>This read-only property lets us find out the maximum size of a window allowed by the operating system. It&#8217;s a <em>flash.geom.Point</em> object with <em>Point.x </em>representing the <em>width</em>, and <em>Point.y</em> representing the height.</p>
<h3>NativeWindow.systemMinSize</h3>
<p>Similarly, thisy property lets us find out the minimum size of a window allowed by the operating system. Again, it&#8217;s a <em>flash.geom.Point</em> object with <em>Point.x </em>representing the maximum <em>width</em>, and <em>Point.y</em> representing the maximum <em>height</em>.</p>
<h3>NativeWindow.title</h3>
<p>This property lets us set the window title. Assuming we are using system chrome, the title will be displayed in the title bar, and also in other OS-specific locations such as the Windows taskbar.</p>
<h3>NativeWindow.transparent</h3>
<p>This Boolean tells us whether or not the window supports transparency. The value is set using the NativeWindowInitOptions instance, passed to the constructor, and cannot be modified once the window has been created. This property also relies upon the <em>supportsTransparency </em>property (see above) being equal to <em>true</em>.</p>
<h3>NativeWindow.type</h3>
<p>This read-only property tells us what window type setting was chosen when the window was created. The property will match one of the string constants defined in the<em> NativeWindowType</em> class. The <em>type </em>is originally specified in the <em>NativeWindowInitOptions</em> class which is passed to the <em>NativeWindow</em> constructor and <strong>cannot </strong>be altered once the window has been created.</p>
<h3>NativeWindow.visible</h3>
<p>This boolean allows us to control whether or not the window is visible. A window which is invisible will still be accessible, and all its methods and properties will still exist, it just will be hidden.</p>
<p>When a window is first created, it&#8217;s <em>visible </em>property will default to <em>false</em>. To show a window, you have to either call the <em>activate </em>method or set the <em>visible </em>property to true.</p>
<h3>NativeWindow.width</h3>
<p>The width of the window <strong>including </strong>any system chrome. To access the width of the usable area within the system chrome, use <em>stage.stageWidth</em>.</p>
<h3>NativeWindow.x</h3>
<p>This property is the horizontal co-ordinate of the window&#8217;s top left corner relative to the operating system&#8217;s desktop.</p>
<h3>NativeWindow.y</h3>
<p>This property is the vertical co-ordinate of the window&#8217;s top left corner relative to the operating system&#8217;s desktop. There are two ways to programmatically reposition a <em>NativeWindow</em>. Either set it&#8217;s <em>x </em>and <em>y </em>properties to new values, or set the <em>bounds</em> property as described above.</p>
<h3>That&#8217;s it!</h3>
<p>So that&#8217;s all the properties of the <em>NativeWindow</em> class &#8211; there&#8217;s quite a few of them, but there&#8217;s nothing too complicated in there. In the second part of this post I&#8217;ll list the public methods exposed by <em>NativeWindow</em>.</p>
<p>Update: Part 2 of this post <a href="/blog/2008/08/10/nativewindow-using-air-windows-with-actionscript-part-2-of-3/">can be found here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lowpitch.com/blog/nativewindow-working-with-air-windows-with-actionscript-part-1-of-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NativeWindowInitOptions &#8211; configure your AIR NativeWindow</title>
		<link>http://lowpitch.com/blog/nativewindowinitoptions-configure-your-air-nativewindow/</link>
		<comments>http://lowpitch.com/blog/nativewindowinitoptions-configure-your-air-nativewindow/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 21:45:35 +0000</pubDate>
		<dc:creator>lowpitch</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Actionscript 3.0]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AS 3.0]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://lowpitch.com/blog/?p=13</guid>
		<description><![CDATA[In a previous post I listed some code to create and activate a NativeWindow in an Actionscript AIR project without really explaining what was going on behind the scenes. In this post, I&#8217;ll explain a little more about the NativeWindowInitOptions class, and how you can control the appearance and behaviour of the NativeWindow that you [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a title="_blank" href="http://lowpitch.com/blog/2008/08/06/nativewindow-nativewindowinitoptions-creating-air-projects-with-actionscript/" >previous post</a> I listed some code to create and activate a <em>NativeWindow</em> in an Actionscript AIR project without really explaining what was going on behind the scenes. In this post, I&#8217;ll explain a little more about the <em>NativeWindowInitOptions</em> class, and how you can control the appearance and behaviour of the <em>NativeWindow</em> that you create.</p>
<p>The code I used in the previous post was this:</p>
<div class="codecolorer-container actionscript"><div class="codecolorer" style="font-family: monospace;"><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="kw2">var</span> mainWindow:NativeWindow = <span class="kw2">new</span> NativeWindow<span class="br0">&#40;</span>windowOptions<span class="br0">&#41;</span>;</div></div>
<p>Fairly obviously, the <em>NativeWindow</em> constructor accepts an instance of <em>NativeWindowInitOptions</em> as its first parameter. In the previous example, I&#8217;m not doing anything fancy with the <em>NativeWindowInitOptions</em> instance that I create, I just create a new instance of the class and pass it to the <em>NativeWindow</em> constructor. As a result, all the various properties will have their default values, and the <em>NativeWindow</em> will be totally default. How terribly dull. Here&#8217;s a list of properties of <em>NativeWindowInitOptions</em> that you can play with to control how the <em>NativeWindow</em> will look and behave when it&#8217;s created&#8230;.</p>
<p><span id="more-13"></span></p>
<h3>NativeWindowInitOptions.minimizable</h3>
<p>This is pretty obvious, but if the <em>minimizable</em> property is set to <em>true</em> then the <em>NativeWindow</em> will be minimizable. Otherwise, it won&#8217;t. This can have knock-on consequences on the appearance of the window. For example, when running on Windows, the value of this property can affect the window menu, and the window minimize button. If you don&#8217;t manually set this property, it will default to <em>true</em>.</p>
<h3>NativeWindowInitOptions.maximizable</h3>
<p>Again, if the <em>maximizable</em> property is set to <em>true</em> then the NativeWindow will be <em>maximizable</em>. This property may also affect the appearance of the window on some operating systems. This property also defaults to <em>true</em>.</p>
<h3>NativeWindowInitOptions.resizable</h3>
<p>The <em>resizable</em> property controls whether or not the window can be resized. When set to <em>false</em>, the little resize handles won&#8217;t appear in the corner of the window. Again, this property defaults to <em>true</em>.</p>
<p>(<em>Note: When running on OS X, resizable and maximizable must both be set to false to prevent resizing. If you do one and not the other, it won&#8217;t work as expected</em>).</p>
<h3>NativeWindowInitOptions.systemChrome</h3>
<p>The <em>systemChrome</em> property controls how the chrome of your <em>NativeWindow</em> will look. The default value is <em>NativeWindowSystemChrome.STANDARD</em>, and with this value the AIR application will adopt the look of a typical window in the operating system on which it&#8217;s running. So, when your AIR app runs on Windows, the chrome / menu bar / etc. will look like a typical Windows app. When the same app runs on OS X, it&#8217;ll look like a Mac app. The other possible value of this property is <em>NativeWindowSystemChrome.NONE</em>, which essentially hides the default system chrome, enabling you to create your own chrome for your <em>NativeWindow</em>.</p>
<h3>NativeWindowInitOptions.transparent</h3>
<p>This property, which defaults to <em>false</em>, determines whether or not the window supports transparency. If set to <em>true</em>, your window will be blended with the desktop beneath it. In other words, if you have content with an <em>alpha</em> of 0.5, your desktop will be visible through your window.</p>
<p>When this property is set to true, any areas of a window which do not contain a<em> DisplayObject</em>, or that only contain a <em>DisplayObject </em>with an alpha value under a certain threshold, will no longer react to mouse events. If a user clicks one of these &#8220;empty&#8221; areas, the mouse click will be handled by whatever happens to be sitting beneath your window, even though the click may have occurred within your application&#8217;s rectangle. The &#8216;threshold&#8217; mentioned above varies between different operating systems but tends to fall between 0.05 and 0.01.</p>
<p>For those of you who may wish to create an application shaped like a clown&#8217;s face, this property is for you.<br />
(Note: You can only set this property to <em>false</em> if you have also specified a value of <em>NativeWindowSystemChrome.NONE</em> for the <em>systemChrome</em>.)</p>
<h3>NativeWindowInitOptions.type</h3>
<p>There are currently three possible values for this property:</p>
<ul>
<li><strong>NativeWindowType.NORMAL</strong><br />
This is the default value for this property, and a <em>NativeWindow</em> of this type will use standard-sized chrome, and will also show up in the Windows taskbar or OS X window menu. Here is a screen shot of a very basic AIR window of this type running on OS X<br />
<br/><br />
<img class="alignnone size-full wp-image-15" title="NativeWindowType.NORMAL" src="http://lowpitch.com/blog/wp-content/uploads/2008/08/normalchrome.jpg" alt="Screenshot of NativeWindow with type NativeWindowType.NORMAL" /></li>
<li><strong>NativeWindowType.UTILITY</strong><br />
A <em>NativeWindow</em> of this type still uses the system chrome, but in slimmed down form. Additionally, this type of window does not show up in the Windows taskbar or OS X window menu. Here is a screen shot of an AIR window of this type as a comparison.<br />
<br/><br />
<img title="NativeWindowType.UTILITY" src="http://lowpitch.com/blog/wp-content/uploads/2008/08/utilitychrome.jpg" alt="Screenshot of NativeWindow with type NativeWindowType.UTILITY" /></p>
<p><em>(Note: One thing I have noticed about windows of this type is that, on OS X at least, they are not minimizable by default. They are maximizable and resizable, but the minimize button is disabled)</em></li>
<li><strong>NativeWindowType.LIGHTWEIGHT</strong><br />
A <em>NativeWindow</em> of this type has no system chrome, and in fact the value of the <em>systemChrome</em> mentioned above must be set to <em>NativeWindowSystemChrome.NONE</em> for this to work. An example of this type of window might be a notification message, similar to the one that pops up when you recieve a new IM in MSN Messenger, or a new email in Gmail Notifier.</li>
</ul>
<h3>These properties cannot be altered after the NativeWindow has been created</h3>
<p>It is important to mention that <strong>each of these properties must be set on the <em>NativeWindowInitOptions</em> object before you attempt to create your <em>NativeWindow</em></strong>. If you create your <em>NativeWindow</em>, passing the <em>NativeWindowInitOptions</em> object in as the parameter, and then subsequently attempt to alter the value of any of these properties, it will have no effect. Once the <em>NativeWindow</em> has been created, the properties mentioned above are set in stone.</p>
<h3>Putting it all together</h3>
<p>Finally, a code sample. The following snippet will create and activate a NativeWindow that supports transparency, has no chrome, is not maximizable, resizable or minimizable, and is of type <em>NativeWindowType.UTILITY</em>, meaning it will not be displayed in the Windows taskbar or OS X window menu. It then adds itself to the stage of the newly created window.</p>
<div class="codecolorer-container actionscript"><div class="codecolorer" style="font-family: monospace;"><span class="kw2">var</span> windowOptions:NativeWindowInitOptions = <span class="kw2">new</span> NativeWindowInitOptions <span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
windowOptions.<span class="me1">minimizable</span> = <span class="kw2">false</span>;<br />
windowOptions.<span class="me1">maximizable</span> = <span class="kw2">false</span>;<br />
windowOptions.<span class="me1">resizable</span> = <span class="kw2">false</span>;<br />
windowOptions.<span class="kw3">type</span> = NativeWindowType.<span class="me1">UTILITY</span>;<br />
windowOptions.<span class="me1">systemChrome</span> = NativeWindowSystemChrome.<span class="me1">NONE</span>;<br />
windowOptions.<span class="me1">transparent</span> = <span class="kw2">true</span>;<br />
<span class="kw2">var</span> nativeWindow:NativeWindow = <span class="kw2">new</span> NativeWindow <span class="br0">&#40;</span>windowOptions<span class="br0">&#41;</span>;<br />
nativeWindow.<span class="me1">activate</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
nativeWindow.<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>At some point soon I will try to write up the <em>NativeWindow</em> class in more detail, including listing the properties it offers, and the events that it dispatches.</p>
]]></content:encoded>
			<wfw:commentRss>http://lowpitch.com/blog/nativewindowinitoptions-configure-your-air-nativewindow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
