# Centering in the stage

**URL:** https://forum.kirupa.com/t/centering-in-the-stage/258394
**Category:** Uncategorized
**Created:** [April 23, 2008, 4:50pm UTC](https://forum.kirupa.com/t/centering-in-the-stage/258394 "2008-04-23T16:50:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![peejay](https://avatars.discourse-cdn.com/v4/letter/p/51bf81/32.png) [@peejay](https://forum.kirupa.com/u/peejay)
#### Post date: [April 23, 2008, 4:50pm UTC](https://forum.kirupa.com/t/centering-in-the-stage/258394/1 "2008-04-23T16:50:39Z")

</div>

Hi, I have an image gallery but at the moment the image is aligning top left in the window. I would like it to center in the stage if possible.

The code I have at the moment is:

function setPositions () {  
container.img.\_x = (Stage.width-container.img.\_width)/2;  
container.img.\_y = (Stage.height-container.img.\_height)/2;  
}

Could some one please help me with the right code to center the container in the stage?

THanks in advance, it’s really appreciated!

pj

---

<div class="post-metadata">

### Author: ![rollwithit80](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@rollwithit80](https://forum.kirupa.com/u/rollwithit80)
#### Post date: [June 13, 2008, 3:38pm UTC](https://forum.kirupa.com/t/centering-in-the-stage/258394/2 "2008-06-13T15:38:26Z")

</div>

For some reason the mc i am trying to center, when the values are set to \_x=0 and \_y=0, the mc is centered in the middle of the main mc at the top left corner of the mc.

Does anyone know why this occurs?

So therefore it doesn’t work for me.

instead i did

```auto
this.imageMC._x = 0-(this.imageMC._width/2)

```
