# Stage resizing

**URL:** https://forum.kirupa.com/t/stage-resizing/278683
**Category:** Uncategorized
**Created:** [January 3, 2009, 4:59pm UTC](https://forum.kirupa.com/t/stage-resizing/278683 "2009-01-03T16:59:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![scarjoh](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@scarjoh](https://forum.kirupa.com/u/scarjoh)
#### Post date: [January 3, 2009, 4:59pm UTC](https://forum.kirupa.com/t/stage-resizing/278683/1 "2009-01-03T16:59:18Z")

</div>

i have picture(s) for my background which are 1024x768 in size;

and i am loading the picture into a movieClip with new Loader();

the movieClip is initially located at 0,0 because the stage size is equal to the picture size.

* * *

now i am trying to set a stage resize function to work like this:

if the stage is scaled for example to 1680x1050 i want that the picture scales to: stage.stageWidth, but i also want for it to always remain proportional.

so the size of the movieClip which holds my Loader would in this case have to be: 1680x1260 for a picture to remain proportional;

so, i would always say: (fullContainer\_mc is the name of the movieClip)

```
fullContainer_mc.width = stage.stageWidth; 
fullContainer_mc.height = ?;

```

so the first question is how to calculate this second number?

and what i also want, is if the picture is wider or higher than the screen (after resizing), to center it like its shown on the picture:

[![](http://img213.imageshack.us/img213/638/60937527jw4.jpg)](http://imageshack.us)

i think i can do it this way:

fullContainer\_mc.y = (stage.stageHeight / 2) - (fullContainer\_mc.height / 2);  
fullContainer\_mc.x = (stage.stageWidth / 2) - (fullContainer\_mc.width / 2);

* * *

i have found some code which looks like it does something similar, but i still havent figured out how to calculate fullContainer\_mc.height = ? to begin with :\*(

```
                 var targetRatio:Number = stage.stageWidth / stage.stageHeight; // stage ratio
   var destinationRatio:Number = fullContainer_mc.width / fullContainer_mc.height; // movieClip ratio

    if (targetRatio &gt; destinationRatio) {
        fullContainer_mc.height = stage.stageHeight;
        fullContainer_mc.scaleX = fullContainer_mc.scaleY;
    } else {
        fullContainer_mc.width = stage.stageWidth;
        fullContainer_mc.scaleY = fullContainer_mc.scaleX;
    }
    
    fullContainer_mc.x = (stage.stageWidth / 2) - (fullContainer_mc.width / 2);
    fullContainer_mc.y = (stage.stageHeight / 2) - (fullContainer_mc.height / 2);
```
