Flex component have to be parented by a SystemManager or another Flex 
Component.  Use Window and put your canvas in there.

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: [email protected] [mailto:[email protected]] On Behalf 
Of thedauntless_ff
Sent: Tuesday, August 25, 2009 5:34 PM
To: [email protected]
Subject: [flexcoders] Add mxml component to NativeApplication instance



Hi,

Situation:
I've simplified my problem to just a few lines of AS & mxml (see below). What 
I'm trying to do is easy: Create a custom NativeWindow instance that has an 
mxml component as it's child.

Problem:
I can't get the component to show and it 'disappears' for some reason.

Code:

package
{
import flash.display.NativeWindow;
import flash.display.NativeWindowInitOptions;
import flash.display.NativeWindowSystemChrome;

public class CanvasWindow extends NativeWindow
{
public function CanvasWindow()
{
var options:NativeWindowInitOptions = new NativeWindowInitOptions();
options.systemChrome = NativeWindowSystemChrome.STANDARD;
options.transparent = false;
super(options);

var ct:CanvasTest = new CanvasTest();
trace("ct = " + ct);
this.stage.addChild(ct);
trace("ct = "+ ct);
}

}
}

####################################################################

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"; width="400" height="300">
<mx:Button x="178" y="138" label="Button"/>
</mx:Canvas>
####################################################################
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"; 
layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.core.Window;

public function init():void
{

var newWindow:NativeWindow = new CanvasWindow();
newWindow.activate();

}
]]>
</mx:Script>
</mx:WindowedApplication>

As you can see I've added two traces. The first traces my CanvasTest instance, 
while the second one traces null. The component is also not displayed.

I couldn't find a lot of information about this, and what I did find was about 
an alpha about Apollo (hacked together).

So, what's going wrong here?

Thanks for reading!

Reply via email to