# Stage Nightmare

**URL:** <https://forum.kirupa.com/t/stage-nightmare/263734>\
**Category:** flash\
**Created:** [June 18, 2008, 7:32pm UTC](https://forum.kirupa.com/t/stage-nightmare/263734 "2008-06-18T19:32:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![asthyanax](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@asthyanax](https://forum.kirupa.com/u/asthyanax)\
**Post date:** [June 18, 2008, 7:32pm UTC](https://forum.kirupa.com/t/stage-nightmare/263734/1 "2008-06-18T19:32:20Z")

</div>

Hi everybody,  
After years of as, i finally look at AS3…it’s a nightmare for me right now since a lot of things have changed.  
So now my problem is with the stage. I just want to change the x and y of a simple movie clip. I have a resize handler that do that…no problem. But my clip at the beginning is not positionning where i want to.  
a simple :

```php

MovieClip(background).x=stage.stageWidth/2;
MovieClip(background).y=stage.stageHeight/2;

```

doesn’t work when it loads. On the resiezHandler yes but not at the beginning…even with an activateHandler function. Do i missed something ?? I’m pretty lost.  
I even found that : [http://tush.wordpress.com/2007/06/25/action-script-3-resize-swf-on-browser-resize/](http://tush.wordpress.com/2007/06/25/action-script-3-resize-swf-on-browser-resize/)  
But i can’t make it work. A basic example or just an explanation of what i do wrong would be appreciated.  
Thank’s for your help

---

<div class="post-metadata">

**Author:** ![snickelfritz](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@snickelfritz](https://forum.kirupa.com/u/snickelfritz)\
**Post date:** [June 18, 2008, 8:38pm UTC](https://forum.kirupa.com/t/stage-nightmare/263734/2 "2008-06-18T20:38:49Z")

</div>

Here’s a basic AS3 liquid GUI script that might be helpful.  
Includes a tiled background image, and a movieclip centered on the stage.

```auto
/*---------------------------------------------------------------------------------
Library: tilable bitmap, class name "Background"
on Stage: movieclip, instance name "centered_mc" with centered registration point.
---------------------------------------------------------------------------------*/
stop();
import flash.display.StageScaleMode;
import flash.display.StageAlign;
import flash.events.Event;

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeHandler);

function resizeHandler(event:Event=null):void {
var sw:Number = stage.stageWidth;
var sh:Number = stage.stageHeight;

var canvas:Sprite = new Sprite;
addChild(canvas);
canvas.graphics.beginBitmapFill(new Background(0, 0));
canvas.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
canvas.graphics.endFill();

addChild(centered_mc);//move to the top of the display list
centered_mc.x = sw/2;
centered_mc.y = sh/2;
}

resizeHandler(null);

```

---

<div class="post-metadata">

**Author:** ![asthyanax](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@asthyanax](https://forum.kirupa.com/u/asthyanax)\
**Post date:** [June 18, 2008, 10:12pm UTC](https://forum.kirupa.com/t/stage-nightmare/263734/3 "2008-06-18T22:12:30Z")

</div>

Thank you. I had that kind of code but i just understood what i did wrong, it was stupid. I didn’t have my clip where i put the code. Thank’s anyway.
