0 Replies Latest reply: Aug 7, 2010 9:31 AM by roelofroos RSS

    Getting the document object cross-window

    roelofroos

      Hello,

       

      I've been working on this application in which I have 2 windows.

       

      Now the main window needs to make a call to the sub window sending a single function.

       

      I have the following code to create the window:

       

      var options = new air.NativeWindowInitOptions();
      options.systemChrome = "none";
      options.type = "lightweight";
      options.resizable = true;
      options.maximizable = true;
      var winwid = 600;
      var winhei = 500;
      var mainWidowPos = new Array();
      var mainWindowPos = getTopLeft(winwid,winhei); //This function is to calculate the center of the screen
      var windowBounds = new air.Rectangle(mainWindowPos[0],mainWindowPos[1],winwid,winhei);
      newHTMLLoader = air.HTMLLoader.createRootWindow(true, options, true, windowBounds); 
      newHTMLLoader.load(new air.URLRequest(url));
      

       

       

      Now that that window is created I need to make a call from window 1 to window 2 (the newly created one, the title of the window is SCR2_BILL).

       

      Maybe this table can clear it up:

       

       

      Window 1 (main)Window 2 (created by code)

      This code is in window 1 and is being called:

       

      for (var i = 0; i < air.NativeApplication.nativeApplication.openedWindows.length; i++) {
           if(air.NativeApplication.nativeApplication.openedWindows[i].title == "SCR2_BILL") {
                air.NativeApplication.nativeApplication.openedWindows[i].window.htmlLoader.stage.nativeWindow.hideBill();
           }
      }
      
      function hideBill() {
           document.getElementById('bill').style.display = 'none';
      }
      

       

      The link does not exist because air.NativeApplication.nativeApplication.openedWindows[i].window.htmlLoader.stage.nativeWin dow is not an object. Does anyone know what the object is after openedWindows[i] which I can use to call functions from the document?

       

      Thanks in advance,

       

      Roelof

       

      PS: the code window 2 is executing is working, it has been tested.