# A dynamic 100% width and scaleX

**URL:** <https://forum.kirupa.com/t/a-dynamic-100-width-and-scalex/233674>\
**Category:** flash\
**Created:** [July 25, 2007, 9:48pm UTC](https://forum.kirupa.com/t/a-dynamic-100-width-and-scalex/233674 "2007-07-25T21:48:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshchernoff](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshchernoff/32/1852_2.png) [@joshchernoff](https://forum.kirupa.com/u/joshchernoff)\
**Post date:** [July 25, 2007, 9:48pm UTC](https://forum.kirupa.com/t/a-dynamic-100-width-and-scalex/233674/1 "2007-07-25T21:48:35Z")

</div>

The idea is that I have a box the first is scaled to the width of the stage meaning (box.scaleX = 100) == (box.width = stage.stageWidth)

So after I declare that the box’s 100% width is equal to the stage width  
I then want to scale that box by a persent meaning  
(box.scaleX = 50) == 50% or half of the stage’s width

On top of theres alot of code I did not include I know this code is wrong and that is what could use some help one.

Main class

```php

import Box
var testBox = new Box();
testBox.scaleX = 50;

```

Box class

```php

class Box extends Sprite{
        var _scaleX:Number;  
         var child:Sprite; // this is the box localy in the class

        public function get scaleX():Number{
              return _scaleX;
        }
        public function set scaleX(scale:Number):void{
              _scaleX = 100 / stage2.stageWidth;
              child.scaleX = scale / scaleX;
        }
        public function Box(){
             /**
             * Make a box at the same width as the stage
             * code not included
             */ 
       }
}

```
