# Stage property

**URL:** <https://forum.kirupa.com/t/stage-property/256035>\
**Category:** flash\
**Created:** [March 29, 2008, 5:33pm UTC](https://forum.kirupa.com/t/stage-property/256035 "2008-03-29T17:33:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![snozbunny](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@snozbunny](https://forum.kirupa.com/u/snozbunny)\
**Post date:** [March 29, 2008, 5:33pm UTC](https://forum.kirupa.com/t/stage-property/256035/1 "2008-03-29T17:33:39Z")

</div>

I’m starting to get into AS3 and I need a bit of help with understanding the stage property. I understand you can access it from the main class but what I’m not able to grasp is why I need to extend Sprite to get it working. Is this a proper way to do it?

```php
package {
    import flash.display.Sprite;
    import flash.display.Stage;
    import flash.display.StageScaleMode;
    import flash.display.StageAlign;
    import flash.display.MovieClip;
    import flash.display.StageDisplayState;

    public class index extends Sprite {

        private var centerStage:MovieClip = new MovieClip;

        public function index():void
        {
            createCenterStage();
        }

        private function createCenterStage():void
        {
            addChild(centerStage);
            stage.addEventListener(Event.RESIZE, centerContainer);
            centerStage.addEventListener(Event.ADDED, centerContainer);
        }
        
        private function centerContainer(event:Event):void
        {
            centerStage.x = Math.round((stage.stageWidth/2)-(centerStage.width/2));
            centerStage.y = Math.round((stage.stageHeight/2)-(centerStage.height/2));
        }
    }
}

```

Well I know my code works but I’d just like to know if there’s a better way to do this since I want to learn the proper way to do things. Thanks in advance!
