# Trouble centering movieClip

**URL:** <https://forum.kirupa.com/t/trouble-centering-movieclip/204900>\
**Category:** Uncategorized\
**Created:** [October 24, 2006, 1:48pm UTC](https://forum.kirupa.com/t/trouble-centering-movieclip/204900 "2006-10-24T13:48:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Navarone](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@Navarone](https://forum.kirupa.com/u/Navarone)\
**Post date:** [October 24, 2006, 1:48pm UTC](https://forum.kirupa.com/t/trouble-centering-movieclip/204900/1 "2006-10-24T13:48:42Z")

</div>

I am having trouble centering my loaded movieClip. I have a blank mc on the stage called _pieceContainer_ and I can’t seem to get the loaded swf to be equally centered around the x,y of the pieceContainer. Can some one help?

```auto

function newPiece() {
 // create a movieclip to hold the functionality of the peice of furniture
 // keep all the furniture inside 1 clip (called 'pieceContainer') for organizational purposes
 var count:Number = pieceContainer.getNextHighestDepth();
 var item_mc:MovieClip = pieceContainer.createEmptyMovieClip("item_mc"+count, count);
 // create a container to load the furniture swf into
 var container:MovieClip = item_mc.createEmptyMovieClip("container_mc", 0);
 container._x = 0;
 container._y = 0;
 // 
 // setup a MCL to handle the swf's loading, when its loaded, apply the mdar methods to it. 
 item_mc.mcl = new MovieClipLoader();
 item_mc.mcl.addListener(mclListener_2);
 item_mc.mcl.loadClip("decals/"+this.piece+".swf", container);
 //
}
//
var mclListener_2:Object = new Object();
mclListener_2.onLoadInit = function(mc:MovieClip) { 
 //
 var pxw = pieceContainer._x
 var pxh = pieceContainer._y
 trace(pxw)
 trace(pxh)
 // set variables to remember the original dimensions
 var axw = mc._width;
 var axh = mc._height;
 trace(axw);
 trace(axh); 
 trace(mc._x)
 trace(mc._y)
 // center piece 
 mc._y = -axw/2;
 mc._x = -axh/2;

```
