Create new window in Air Application
ho开发者_StackOverflow中文版w 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>
精彩评论