2

how to create new window(same application duplicate) in Air Project. Any one Help thanks.

Rajkamal
  • 355
  • 1
  • 5
  • 19

1 Answers1

1

Use mx:Window, and take your code out of mx:WindowedApplication and put it into a reusable Canvas. The put an instance of that back in mx:WindowApplication, and then you can create a new mx:Window and add your reusable Canvas component in there as well.

<mx:WindowedApplication ...>
   <p:YourComponent ... />  <!-- by putting it in your own file you can reuse it -->
</mx:WindowedApplication>

In a separate file called YourComponent.mxml:

<mx:Canvas ...>
   <!-- put the contents that's in WindowedApplication here -->

   <!-- add this block to your script block, and hook up a button/menu/whatever to 
        invoke this function.  See how it creates a new instance of Window, adds a
        new instance of YourComponent (which is the guts of your app), and shows that.
    -->
   <mx:Script>
       private function createNewWindow() : void {
           var window : Window = new Window();
           var yourComponent : YourComponent = new YourComponent();
           // initialize yourComponent instance's properties

           window.addChild( yourComponent );
           window.width = 800;
           window.height = 600;
           window.open(true);
       }
   </mx:Script>
</mx:Canvas>
chubbsondubs
  • 34,812
  • 24
  • 97
  • 134
  • I want duplicate(current Air Application) of the application in new window – Rajkamal Jul 27 '11 at 15:01
  • Right so create a new instance of Window, window.addChild( new YourComponent() ), and window.visible = true. The point of what I wrote was to refactor what made up your AIR app into a reusable separate Canvas file. – chubbsondubs Jul 27 '11 at 15:05
  • how can i use airApplication.xml for duplicate. sorry, i can't understand can u send any example or link to create duplicate(total application) air Application – Rajkamal Jul 27 '11 at 15:18
  • You can't simply create a duplicate of your entire application. However, you can take what constitutes your entire application (i.e. the children of WindowedApplication, move that into a separate MXML component with a Canvas). Then reuse it just like you do DataGrid, List, Button, etc. – chubbsondubs Jul 27 '11 at 17:08