Skip to main content
Inspiring
July 11, 2013
Question

NativeApplication is Null on Windows

  • July 11, 2013
  • 2 replies
  • 564 views

Hi,

I'm finding that the following line of code is returning a null nativeWindow object on Windows 7. It works fine however on Mac. Is this a know bug?

NativeApplication.nativeApplication.activeWindow.height

And, what would be a workaround? I need this info in order to subtract the stage height in order to determine the window's title bar height.

This topic has been closed for replies.

2 replies

leejkAuthor
Inspiring
July 11, 2013

This code works perfectly on the Mac, but fails miserably on Windows.

private function stage_resizeHandler(event:Event):void

{

                              var sanitizedStageHeight:Number;

                              var sanitizedStageWidth:Number;

                              var stageAspectRatio:Number = stage.stageWidth / stage.stageHeight;

                              //var chromeHeight:Number = NativeApplication.nativeApplication.activeWindow.height - stage.stageHeight;

                              var chromeHeight:Number = stage.nativeWindow.bounds.height - stage.stageHeight;

                              //var windowBorders:Number = NativeApplication.nativeApplication.activeWindow.width - stage.stageWidth;

                              var windowBorders:Number = stage.nativeWindow.bounds.width - stage.stageWidth;

                              //if stage width is greater than application aspect ratio then base the width on the stage height

                              if (stageAspectRatio > 1.33333333)

                              {

                                        sanitizedStageHeight = stage.stageHeight;

                                        sanitizedStageWidth = (stage.stageHeight / (768 - chromeHeight)) * 1024;

                              }

                              else

                              {

                                        sanitizedStageHeight = (stage.stageWidth / (1024 - windowBorders)) * 768;

                                        sanitizedStageWidth = stage.stageWidth;

                              }

                              this.scaleX = sanitizedStageWidth / (1024 - windowBorders);

                              this.scaleY = sanitizedStageHeight / (768 - chromeHeight);

                              this.x = (NativeApplication.nativeApplication.activeWindow.width - (this.scaleX * 1024)) / 2;

}

The other bug with using bounds is that it's value return the value from before the resize event was fired instead of what it is after the resize, which is completely useless.

leejkAuthor
Inspiring
July 11, 2013

And this is wrong too on Windows, stage.nativeWindow.bounds.height

???