I was playing around with the NativeWindow API the past couple of days and I ran into a roadblock. With Native Windows you create them and then you’re supposed to be able to add stuff to the display list using the addChild() method. But when I tried to add any kind of Flex Component, it wouldn’t work (reading the docs more closely confirmed that). Thanks to Sasha Magee from the engineering team I know why, and it’s pretty obvious.
The NativeWindow class doesn’t support all of the “Flex stuff” out of the box. It doesn’t know how to handle popping up a combo box, how to layout components or any of the “Flex smarts” as Sasha calls it. So when you try to add a component to the NativeWindow you’ve just created, it won’t work.
What I had to do was change the base class of my custom component from mx:Canvas to mx:Window. Now in order to create a window I just create a new instance of that component (in this case WaypointEditor), set the height and width, then call the open() method:
var wptEditor : WaypointEditor = new WaypointEditor();
wptEditor.height = 500;
wptEditor.width = 500;
One other thing I noticed is that when doing Native Windows you can't call the acvitate() method that the documents use. You have to call open() in order to pop it up. Once you've created the window with the base class of mx:Window you can add any other Flex components to the display list. So if you don't want to have to change your custom component to mx:Window you can just create a custom component with mx:Window and nothing else, then create that and add your other custom component to the window using addChild().
[tags]Flex, AIR, NativeWindow[/tags]Tweet