简体   繁体   中英

Create new window in Air Application

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM