1 Reply Latest reply on Aug 14, 2007 2:35 AM by Karl_Sigiscar_1971

    Force Aspect Ratio

    John Cambridge
      My application acts funky if it's resized to really strange aspect ratio. What's the best way to force my application to always stay in a 16:9 aspect ratio, and show black bars on the top and bottom if necessary?

      Thanks!
        • 1. Re: Force Aspect Ratio
          Karl_Sigiscar_1971 Level 3

          Hello John,

          Actually, I ran into the same problem. I have a Flash piece of content included into a Flex application as a Flex component. While the Flex application should resize to fit the page, the game itself should keep it 4:3 aspect ratio. I found no easy way of doing this (neither using any Flex properties nor using the stage.scaleMode properties worked). I did it my own way:

          // Game aspect ratio constants

          private static const GAME_WIDTH:uint = 800;
          private static const GAME_HEIGHT:uint = 650;
          private static const ASPECT_RATIO:Number = (GAME_HEIGHT / GAME_WIDTH);

          <game:Game id="game"
          width="{ GAME_PADDING_LEFT + this.gameContainerCanvas.width }"
          height="{ GAME_PADDING_TOP + this.gameContainerCanvas.width * ASPECT_RATIO }">

          The idea is to constrain the width to the height or the height to the width in order to keep the aspect ratio.

          Cheers,
          Karl.