2 Replies Latest reply on Mar 10, 2010 7:11 PM by gcollins2

    Center HtmlLoader window

    gcollins2 Level 1

      How do I center an html window?

       

      When my app runs I maximize the native window in my html page using onload() and I want to center my popup window in the center of the app window (not screen)

       

      Here is my code in my html page to open the window but how do I center it

       

      function openWin() {

        var options = new air.NativeWindowInitOptions();
        options.systemChrome = "standard";
        options.type = "utility";
       
        
        var windowBounds = new air.Rectangle(200,200,708,531);
        newHTMLLoader = air.HTMLLoader.createRootWindow(true, options, true, windowBounds);
        newHTMLLoader.load(new air.URLRequest("app/Unit 3/Lesson 1/breaks.swf"));
      }

        • 1. Re: Center HtmlLoader window
          Jeff Swartz Level 3

          Try this:

           

          function openWin() {
            var options = new air.NativeWindowInitOptions();
            options.systemChrome = "standard";
            options.type = "utility";

            winWidth = 708;
            winHeight = 531;
            winX = nativeWindow.x + (nativeWindow.width - winWidth)/2;
            winY = nativeWindow.y + (nativeWindow.height - winHeight)/2;
            var windowBounds = new air.Rectangle(winX, winY, winWidth, winHeight);
            newHTMLLoader = air.HTMLLoader.createRootWindow(true, options, true, windowBounds);

            newHTMLLoader.load(new air.URLRequest("app/Unit 3/Lesson 1/breaks.swf"));
          }

          • 2. Re: Center HtmlLoader window
            gcollins2 Level 1

            Ah yah!!!

             

            Just started working with adobe air yesterday and I couldn't figure out the nativeWindow.x and y

             

            Thank you very much.