如何在 Air Project 中创建新窗口(相同的应用程序副本)。任何一个帮助谢谢。
问问题
1156 次
1 回答
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>
于 2011-07-27T14:57:37.520 回答