# Fullscreen image... to an extent

**URL:** <https://forum.kirupa.com/t/fullscreen-image-to-an-extent/279185>\
**Category:** flash\
**Created:** [January 11, 2009, 12:47am UTC](https://forum.kirupa.com/t/fullscreen-image-to-an-extent/279185 "2009-01-11T00:47:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lordy18](https://avatars.discourse-cdn.com/v4/letter/l/2acd7d/32.png) [@lordy18](https://forum.kirupa.com/u/lordy18)\
**Post date:** [January 11, 2009, 12:47am UTC](https://forum.kirupa.com/t/fullscreen-image-to-an-extent/279185/1 "2009-01-11T00:47:07Z")

</div>

Hey,

I know how to make an image full screen, also with a onresize listener. But! Because some of the images are only of a certain pixel size, I don’t want to stretch them above that.

So, do any of you know how to set limitations?

The code I am using is:

tree\_mcHeight = new Object ();  
tree\_mcHeight = tree\_mc.\_height / tree\_mc.\_width;

tree\_mcWidth = new Object ();  
tree\_mcWidth = tree\_mc.\_width / tree\_mc.\_height;

if ((Stage.height / Stage.width) \< tree\_mcHeight) {  
tree\_mc.\_width = Stage.width;  
tree\_mc.\_height = tree\_mcHeight \* tree\_mc.\_width;  
} else {  
tree\_mc.\_height = Stage.height;  
tree\_mc.\_width = tree\_mcWidth \* tree\_mc.\_height;  
};

tree\_mc.\_x = Stage.width / 2;  
tree\_mc.\_y = Stage.height / 2;

sizeListener = new Object();

// make listener change picture size and center picture on browser resize  
sizeListener.onResize = function() {

if ((Stage.height / Stage.width) \< tree\_mcHeight) {

tree\_mc.\_width = Stage.width;  
tree\_mc.\_height = tree\_mcHeight \* tree\_mc.\_width;  
} else {  
tree\_mc.\_height = Stage.height;  
tree\_mc.\_width = tree\_mcWidth \* tree\_mc.\_height;  
};

tree\_mc.\_x = Stage.width / 2;  
tree\_mc.\_y = Stage.height / 2;

}

//add listener to stage  
Stage.addListener(sizeListener);

It would be nice to change the background colour surrounding the image when it resizes as much as possible.

If needed, I can post an fla…

Thanks in advance,

Chris.
