# Centering an mc

**URL:** <https://forum.kirupa.com/t/centering-an-mc/166311>\
**Category:** Uncategorized\
**Created:** [October 18, 2005, 8:52pm UTC](https://forum.kirupa.com/t/centering-an-mc/166311 "2005-10-18T20:52:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kritikal](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kritikal/32/1699_2.png) [@kritikal](https://forum.kirupa.com/u/kritikal)\
**Post date:** [October 18, 2005, 8:52pm UTC](https://forum.kirupa.com/t/centering-an-mc/166311/1 "2005-10-18T20:52:58Z")

</div>

hey guys,

here’s the deal, I have a main swf named index.swf with only 1 frame, on that frame I have actionscript that creates an empty movieclip loads an external swf and centers it depending on the user’s browser size.

My problem is if I load an swf that doesn’t take the whole 1020x610 of the index.swf it won’t be centered. It’s kind of hard to explain. so here’s some of the code.

```auto

this.createEmptyMovieClip("container",this.getNextHighestDepth());

container.loadMovie("../swf/splash.swf");

var stageXCenter:Number = Stage.width * .5;
var stageYCenter:Number = Stage.height * .5;

stageXCenter = stageXCenter - (container._width * .5);
stageYCenter = stageYCenter - (container._height * .5);

container._x = stageXCenter;
container._y = stageYCenter;

stageListener = new Object();

stageListener.onResize = function():Void {
    stageXCenter = Stage.width * .5;
    stageYCenter = Stage.height * .5;
        
    stageXCenter = stageXCenter - (container._width * .5);
    stageYCenter = stageYCenter - (container._height * .5);

    container._x = stageXCenter;
    container._y = stageYCenter;
}

Stage.addListener(stageListener);

```

Any help would be greatly appreciated
