Owned Windows in AIR 2.6

One of the new desktop features in AIR 2.6 is owned windows. Owned windows are primarily designed for when you want a utility or a lightweight window to be related to another window as in the case of a tool pallet. The following describes the relationship between owned windows and their owners:

  • Owned windows always have a higher z-order than their owners which means they always appear on top (you wouldn’t want a tool pallet to get lost behind your application window).
  • When you minimize or hide the owner, all owned windows are minimized, as well. When you restore the owner, the owned windows are also restored.
  • When you close the owner, all owned windows also close.

Here’s an example of owned windows in action:

And here’s the code:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx">
            private function openNewWindow(owned:Boolean):void
                var initOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
                initOptions.type = NativeWindowType.UTILITY;
                if (owned) initOptions.owner = this.nativeWindow;
                var newWin:NativeWindow = new NativeWindow(initOptions);
                newWin.title = (owned) ? "Owned Window" : "Normal Window";
    <s:VGroup width="100%" height="100%" verticalAlign="middle" horizontalAlign="center">
        <s:Button label="Open Ownded Window" click="openNewWindow(true);"/>
        <s:Button label="Open Regular Window" click="openNewWindow(false);"/>

8 Responses to Owned Windows in AIR 2.6

  1. Florian says:


  2. Now, why not add an optional setting for the owned window to keep its alignment to the owner? Think at the Windows Winamp application from Nullsoft, for instance. When I move the player window, the play list window moves also. This could be useful in some scenarios.

    On the other hand, it’s pretty weird nobody in the AIR team had time to listen when I proposed such a feature back in the AIR 1.0 good old days 😛

  3. mtofu says:

    Hi Christian ,

    Thanks much. This is really helpful!

    I was wondering if there is a way to use owned windows with Flex framework windows without going into the lower level of accessing the display list (such as loading swf, etc.). It seems spark windows manage their own nativewindow objects?

    Thanks again.

  4. Shane says:

    In case anyone else runs into a runtime error:
    ReferenceError: Error #1056: Cannot create property owner on flash.display.NativeWindowInitOptions.
    please see Christian’s earlier post on configuring AIR 2.6 in Flash Builder:

    Works for me in Flex Builder 3 as well.

  5. Osman says:

    Is there any way to use the owner functionality with the spark window class? We have some pretty complicated MXML windows where we would like to use this feature but I can’t find any examples of how to do this.

  6. Hasan Otuome says:

    @Osman – it’s possible. I’m using the following temporary solution until the SDK is updated to support it -> http://j.mp/gpAbL5

  7. Quentin says:

    Just checking if anyone (including you, Christian) had an easy solution to setup an owned NativeWindow so it is filled with a Spark Window’s content at creation? Seems like a real pain to do, and I haven’t seen anything close to simple to do so!

  8. Mauricio V says:

    @Quentin, After beating my head around this for a while, I finally found a good explanation. Follow this link and just remember to also add the owned property of the NativeWindowInitOptions object.

    In that post, the code references a UIComponent to be added as the content of the NativeWindow, so just turn your Spark Window into a container (eg Group) and move the window specific variables (like systemChrome and trasparent) to the NativeWindowInitOptions object.