3 Replies Latest reply on Aug 8, 2008 5:14 PM by rkado

    Centering application not working

      I know this should be simple, but for some reason this is not working for me.
      I have the following init() function that is called from the applicationComplete event.

      public function init():void {
      // center the window on the screen
      if (this.nativeWindow) {
      var screenBounds:Rectangle = Screen.mainScreen.bounds;
      this.nativeWindow.x = (screenBounds.width - this.nativeWindow.width) / 2;
      this.nativeWindow.y = (screenBounds.height - this.nativeWindow.height) / 2;

      And for some reason the application appears with the top left corner in the middle of the screen. If I call init() after the application is initially displayed (from a button), it centers the application correctly. Even if I hard code values into nativeWindow x&y, it does not seem to be set. It's like the values are read only at the applicationComplete time and then read/write after that.

      What am I doing wrong?