1 Reply Latest reply on Oct 23, 2009 11:52 AM by Joe ... Ward

    calling parent window from child window

    Alex-SM

      Hi,

       

      I am creating a new child air window called "test.html" as follow. How can I call a javascript function in parent window from child window?

       

      function createMyWindow()
      {
          var options = new air.NativeWindowInitOptions();
          options.type = air.NativeWindowType.LIGHTWEIGHT;
          options.systemChrome = air.NativeWindowSystemChrome.NONE;
          options.transparent = true;

          mywindow = air.HTMLLoader.createRootWindow(false, options, false);

          mywindow.load(new air.URLRequest("test.html"));

          ....

      }

       

      Thanks,

      ASM

        • 1. Re: calling parent window from child window
          Joe ... Ward Level 4

          If both parent and child are in the same sandbox, then the easiest way is to have the parent create a reference to itself on the child. You can set the parent and or owner property (or some variable of your own), which isn't done automatically when you use the createRootWindow() function. Use the myWindow reference that the parent has after the complete event for the call to load():

           

          myWindow.window.parent = me.window; //or something similar

           

          If the parent and the child are not in the same sandbox (i.e. the child page is loaded from outside the application) then you have to use a sandbox bridge to allow the child to communicate with the parent.

           

          http://help.adobe.com/en_US/AIR/1.5/devappsflash/WS5b3ccc516d4fbf351e63e3d118666ade46-7f08 .html

           

          Pay attention to the last few paragraphs. You can't create a sandbox bridge directly to content loaded with createRootWindow(). Instead, you have to use a "shim" HTML file that loads the non-application content into an iframe or frame.