sigvardsen
sigvardsen

Reputation: 1531

Multiple Windows in Adobe AIR

Is it possible to have multiple windows-"handles" open in one Adobe AIR application? You can ofcourse make a walkaround by letting the app be transparent, but I am interested in a better solution.

Upvotes: 3

Views: 6852

Answers (3)

sigvardsen
sigvardsen

Reputation: 1531

The following will do the trick (It is Theo's code just corrected a bit):

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="main()">
    <mx:Script>
    <![CDATA[
    import mx.core.Window;

    private function main( ) : void {
        var window:Window;
        for ( var i:int = 0; i < 5; i++ ) {
            window = new Window();
            window.width  = 200;
            window.height = 300;
            window.open(true);
            window.showStatusBar = false;
        }
    }
    ]]>
    </mx:Script>
</mx:Application>

Upvotes: 2

Theo
Theo

Reputation: 132862

The best way to handle this is to make the main class a subclass of Application instead of WindowedApplication, and set the initialWindows visible setting to false. Then, in your main class you create as many Window instances as you want.

Main class:

<Application xmlns="http://www.adobe.com/2006/mxml">
  <applicationComplete>main()</applicationComplete>
  <Script>
  <![CDATA[
  private function main( ) : void {
    var window : Window;
    for ( var i = 0; i < 5; i++ ) {
      window = new Window();
      window.width  = 200;
      window.height = 300;
      window.open(true);
    }
  }
  ]]>
  </Script>
</Application>

App config:

<application xmlns="http://ns.adobe.com/air/application/1.5">
  ...
  <initialWindow>
    ...
    <visible>false</visible>
  </initialWindow>
</application>

Upvotes: 6

Richard Haven
Richard Haven

Reputation: 1154

Why do you want window "handles" ?

The PopupManager lets you create non-modal windows.

Cheers

Upvotes: 0

Related Questions