# Size rectangle with actionscript

**URL:** <https://forum.kirupa.com/t/size-rectangle-with-actionscript/181930>\
**Category:** Uncategorized\
**Created:** [March 14, 2006, 11:39am UTC](https://forum.kirupa.com/t/size-rectangle-with-actionscript/181930 "2006-03-14T11:39:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xeraph](https://avatars.discourse-cdn.com/v4/letter/x/e495f1/32.png) [@Xeraph](https://forum.kirupa.com/u/Xeraph)\
**Post date:** [March 14, 2006, 11:39am UTC](https://forum.kirupa.com/t/size-rectangle-with-actionscript/181930/1 "2006-03-14T11:39:05Z")

</div>

To size a rectangle I use the following actionscript:

```auto

function sizeRectangle() {
    rectangle.onEnterFrame = function() {
        with (rectangle) {
            w = (Stage.width);
            speed = 5;
            _width += (w-_width)/speed;
            if (_width>(w-1)) {
                delete rectangle.onEnterFrame;
                _width = w;
            }
        }
    };
}

```

It all works fine.  
When a certain button is pressed it needs to size itself to zero again.  
This is easy to do by altering “w=(Stage.width);” to “w=0;”.  
What happends is that it will shrink from right to left.  
But how do i code this when I want the rectangle to shrink from left to right?
