I am creating an AIR application that spawns a new window, so there is a main application window and also another window. One can manipulate data in either window, and data is synchronized between the windows. So when I adjust data in the main window, I update the UI and data that’s in the secondary window.
The main window is a document class, and a class represents that which sits in the secondary window. I have updating methods in the secondary class so it’s easy to call them from the document class and have the magic happen.
However, if I change things in my secondary window, I update the UI there and the local copy of the underlying data, and need to tell the document class to do the same. This should be using a database or something so there is only ever one copy of the data both consume, but I was feeling lazy.
Anyway, after pounding my head for 30 minutes on how to access the main window and it’s document class from the class sitting in the spawned window of the AIR application, I finally figured it out.
var who = NativeApplication.nativeApplication.openedWindows.stage.getChildAt(0);
And that does it. You could also just do the following too:NativeApplication.nativeApplication.openedWindows.stage.
getChildAt(0).callTheMethodInDocumentClass(); You can call methods in your main document class from a spawned window in an AIR application, send along whatever parameters you’d like, etc. This is a big time saver now that I figured this out. If this is common knowledge, I didn’t know about it.