在Air Application中创建新窗口

时间:2011-07-27 14:53:00

标签: flex air flexbuilder flashbuilder4 flash-builder4.5

如何在Air Project中创建新窗口(相同的应用程序副本)。任何一个帮助谢谢。

1 个答案:

答案 0 :(得分:1)

使用mx:Window,从mx:WindowedApplication中取出代码并将其放入可重复使用的Canvas中。将一个实例放回mx:WindowApplication中,然后你可以创建一个新的mx:Window并在那里添加你的可重用Canvas组件。

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

在一个名为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>