title: Flex open window behind active window
body: <p>In Flex Air app, how do you open a window behind an active one?</p>
  
  <p>I tried following and i can't seem to get it to work</p>
  
  <pre><code>&lt;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"
                         creationComplete="onCreationComplete(event)"&gt;
  
      &lt;fx:Script&gt;
          &lt;![CDATA[
              import mx.events.FlexEvent;
  
              import spark.components.Window;
  
              private var window1:Window  = new Window();
              private var window2:Window  = new Window();
              private var timer:Timer     = new Timer(3000,1);
  
              private function onCreationComplete(event:FlexEvent):void
              {
                  window1         = new Window();
                  window1.title   = "Window 1";
                  window1.width   = 200;
                  window1.height  = 200;
                  window1.open(false);
                  window1.orderInBackOf(this);
  
                  window2         = new Window();
                  window2.title   = "Window 2";
                  window2.width   = 200;
                  window2.height  = 200;
  
                  timer.addEventListener(TimerEvent.TIMER_COMPLETE, openWindow2, false, 0, true);
                  timer.start();          
              }
  
              private function openWindow2(event:TimerEvent):void
              {
                  window2.open(false);    
                  window2.orderInBackOf(window1);
              }
          ]]&gt;
      &lt;/fx:Script&gt;
  &lt;/s:WindowedApplication&gt;
  </code></pre>
  
  <p>With this code, I would expect window1 to open behind the main app window and, in 3 seconds, window2 would open behind window1. But if you execute this, window1 will open on top of the main window and window2 will open on top of window1 and the main app will retain focus. This seems like a bug in the Flex. If so is there any workaround for this problem? </p>