3 Replies Latest reply on Jul 2, 2008 4:27 PM by Joe ... Ward

    why is my 1px line showing like 10px?

    john isaacks Level 1
      if you create a new AIR application and paste this in:

      var newOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
      var newWindow = new NativeWindow(newOptions);
      var container = new Sprite();
      var container2 = new Sprite();
      container.graphics.lineStyle(1,0,1);
      container.graphics.lineTo(10,10);
      container2.graphics.lineStyle(1,0,1);
      container2.graphics.lineTo(10,10);
      newWindow.stage.stageWidth = stage.stageWidth;
      newWindow.stage.stageHeight = stage.stageHeight;
      newWindow.stage.addChild(container);
      addChild(container2);
      newWindow.activate();

      I create a new window the same size as the current window, and add the exact same thing to both windows, yet it looks completely different in each window?

      why is this?

      THANKS!!!
        • 1. Re: why is my 1px line showing like 10px?
          Damon Edwards Level 3
          try adding:

          newWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
          newWindow.stage.align = StageAlign.TOP_LEFT;
          • 2. Re: why is my 1px line showing like 10px?
            john isaacks Level 1
            quote:

            Originally posted by: dzedward
            try adding:

            newWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
            newWindow.stage.align = StageAlign.TOP_LEFT;



            using NO_SCALE does work, but I am wanting to make something full-screen and I want it to EXACT_FIT into the full screen, but EXACT_FIT DOESNT exactly fit when used on a new window.
            • 3. Re: why is my 1px line showing like 10px?
              Joe ... Ward Level 4
              The short answer is use noScale in AIR. The different scale modes exist so that you can decide which compromise is the least bad when an html page loads your Flash or Flex application into an area that isn't the right size. In AIR, you always control the size of the display area so you never have to make this compromise.

              The longer answer is that the initial window in AIR (like Flash) gets its unscaled size from the SWF file that is loaded. (HTML windows are automatically set to noScale, so this isn't an issue for HTML apps). However, when the stage is created for a new window, there's no SWF file, nor even a window size from which to guess the "natural" unscaled size. Instead AIR assumes that a 72x72 pixel stage is 1:1 scale. Thus if you create a window with a 72x72 pixel stage and draw a 10x10 pixel rectangle, the rectangle will appear on screen as 10x10 (using any scale mode). However, if you did the same thing with a 144x144 pixel stage and any scale mode except noScale, the rectangle will be scaled 1:2 and drawn as a 20x20 rectangle in screen coordinates.

              If you really want to use one of the other scale modes in a new window, you can use the 72px == scale of 1 to calculate a scale factor to manually apply to your content so that it will appear as 1:1 in screen coordinates when your window does not begin life as a 72 pixel square. Things will then scale as you probably expected in the beginning. (See http://www.adobe.com/devnet/air/flex/quickstart/launching_windows.html for an example.)