WindowApplication nested in Application? Flex 4
I am making a desktop application and I am exploring different ways to use application.
When I choose to make an air app it automatically uses WindowApplication but if I want multiple windows in my application, then I need to use Application instead. I was trying to nest WindowApplication inside Application so I can have multiple windows (by Application -> new Window()) and have a chromeless, transparent program in the background. When I nest WindowApplication it works but when I click the WindowApplication (after running debug) it would throw an error: "Argument Error: Error #2025: The supplied DisplayObject must be a child of the caller".
Here is some code I used. I am using Air 2.5 with Flash Builder 4. (the xml file is default).
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
applicationComplete="main()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import spark.components.Label;
import spark.components.Window;
private var windows:Array = new Array();
private function main():void
{
var window:Window;
var numOfWindows:Number = 2;
for(var i:Number=0; i<numOfWindows;i++)
{
window = new Window();
window.width = 300;
window.title = "I am Window #"+i;
window.height = 200;
window.open(true);
window.showStatusBar = false;
windows.push(window);
}
trace("Complete!");
}
]]>
</fx:Script>
<s:WindowedApplication >
<!-- Compiles, but once I click this, it throws the error. -->
</s:WindowedApplication>
</s:Application>
How could I have a transparent application that can control a few windows (or at least get r开发者_高级运维id of the error above)? Thanks in advance.
WindowedApplication is not intended to be used as a child element, it is a top level element. You should use Application or WindowedApplication as your root element, and never try to nest them inside each other. More information in the official language reference: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/WindowedApplication.html
精彩评论