I have a bitmap based flash game (bitmapdata generated screen) that I'm trying to load in to a secondary nativewindow generated from a main flash (not AJAX/HTML) based AIR app that's a graphical menu. I.E. you click on a selection in the menu, and it pops open a secondary nativewindow with the flash game running in it. The problem is, the game itself gets mangled in the secondary window when it loads in. Keyboard input goes away, the bitmap doesn't draw properly (it streaks like its not drawing the background image each frame), most of the game objects its supposed to draw in to the bitmap are missing, etc.
When I make the game itself in to its own AIR app and run it direct, it works just fine. So I'm puzzled. Is there some kind of special coding considerations in the as3 side that I'm missing with the original game? I.E. if a flash based AIR app launches another nativewindow and loads a swf in to that, does it share some kind of variable set, display list, etc. with the calling window? Something else? Any help would be appreciated.
There are a few differences between (A.) letting the AIR runtime load content into the initial window and (B.) loading content into a new NativeWindow.
1. In case A, the stage property is available in the class constructor for the main sprite. In case B, this is not the case. You may have to use an ADDED_TO_STAGE event handler to do some class initialization.
2. In case A, the initial scale is based on the metadata present in the SWF -- this results in the behavior you would expect. In case B, there is no SWF to base the scale on when the window is created, so a default scale is used -- this is rarely results in behavior you would expect (unless the window happens to be created with a size of 72x72 pixels).
If you aren't setting the stage to noScale, then this could account for some of the visual issues. (See http://www.adobe.com/devnet/air/flex/quickstart/launching_windows.html for an explanation of the scaling issues.) The easiest thing to do is to set the Stage scaleMode to noScale and the align property to the top left setting. I'm guessing your drawing code isn't expecting the scaling so things are getting put in the wrong place.
3. In case A, the content is automatically put in the application sandbox. In case B, it depends on the URL.
As for the Keyboard input, this may depend on how you are loading the SWF and from where. This could be related to #3 above, although I would expect to see security errors. How are you adding your keyboard event handlers?