3 Replies Latest reply on Mar 17, 2009 12:00 PM by Techauth

    Air application built using Flash AS3


      Over the last couple of months I have been trying to transition across from AS2 to AS3. I also have been looking at what benefits AIR can provide. Over the last week I have been developing a small usable AIR application for a project I'm heading up in my organization using Flash CS3, however I've come across a small issue I can't seem to resolve.

      I have looked through Google, AIR cookbook, blogs but still can't seem to fix the problem, so I'm hoping a post here will help.

      I want to center the AIR file on the user's screen when they launch it. I would really appreciate any help to resolve this issue.
        • 1. Re: Air application built using Flash AS3
          Jeff Swartz Level 3
          To center the initial window of the AIR application at launch:

          1. Set the visible property of the initialWindow property of the application descriptor file to false. You can do this in Flash CS3 in Publish Settings: Player Settings: Advanced Settings: Visible.

          2. In initialization script for your application, include this ActionScript code (or something like it):

          var screen:Screen = Screen.getScreensForRectangle(stage.nativeWindow.bounds)[0];

          var desiredWidth:Number = 800;
          var desiredHeight:Number = 600;

          var windowBounds:Rectangle = new Rectangle();
          windowBounds.width = Math.min(desiredWidth, screen.bounds.width);
          windowBounds.height = Math.min(desiredHeight, screen.bounds.height);
          windowBounds.x = screen.bounds.x + (screen.bounds.width - windowBounds.width)/2;
          windowBounds.y = screen.bounds.y + (screen.bounds.height - windowBounds.height)/2;

          stage.nativeWindow.bounds = windowBounds;

          stage.nativeWindow.visible = true;
          • 3. Re: Air application built using Flash AS3
            Techauth Level 1
            swartz1999, Many thanks this seems to have worked just the way I wanted.

            Appreciate your time to answer this post.

            Kind regards