# Centering and resizing

**URL:** <https://forum.kirupa.com/t/centering-and-resizing/330280>\
**Category:** Uncategorized\
**Created:** [December 24, 2012, 8:21am UTC](https://forum.kirupa.com/t/centering-and-resizing/330280 "2012-12-24T08:21:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![krizinxgren](https://avatars.discourse-cdn.com/v4/letter/k/ed8c4c/32.png) [@krizinxgren](https://forum.kirupa.com/u/krizinxgren)\
**Post date:** [December 24, 2012, 8:21am UTC](https://forum.kirupa.com/t/centering-and-resizing/330280/1 "2012-12-24T08:21:59Z")

</div>

Good day  
I have followed this AS3 tutorial at

[http://www.kirupa.com/developer/as3/resizing\_centering\_as3.htm](http://www.kirupa.com/developer/as3/resizing_centering_as3.htm)

and its very good contents is centering as nomal but i have one request how can i stop my background image from stretching when window is resized the below code am using is the same from tutorial  
many many thanks.

function init()  
{  
stage.align=StageAlign.TOP\_LEFT;  
stage.scaleMode=StageScaleMode.NO\_SCALE;  
stage.addEventListener(Event.RESIZE, updateSize);  
stage.dispatchEvent(new Event(Event.RESIZE));  
krau.x = 0;  
krau.y = 0;  
}  
init();  
function updateSize(e:Event)  
{  
//Set background’s size  
krau.width = stage.stageWidth;  
krau.height = stage.stageHeight;  
//center content  
emage.x = stage.stageWidth/2 - emage.width/2;  
emage.y = stage.stageHeight/2 - emage.height/2;  
}
