# Adding Items Dynamically to the stage within set boundaries? So Close

**URL:** https://forum.kirupa.com/t/adding-items-dynamically-to-the-stage-within-set-boundaries-so-close/326829
**Category:** Uncategorized
**Created:** [January 15, 2012, 4:07am UTC](https://forum.kirupa.com/t/adding-items-dynamically-to-the-stage-within-set-boundaries-so-close/326829 "2012-01-15T04:07:39Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ChrisW182](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@ChrisW182](https://forum.kirupa.com/u/ChrisW182)
#### Post date: [January 15, 2012, 4:07am UTC](https://forum.kirupa.com/t/adding-items-dynamically-to-the-stage-within-set-boundaries-so-close/326829/1 "2012-01-15T04:07:39Z")

</div>

```auto
            function AddYCoins():void 
            {
                for (var i:int = 0; i < 10; i++)
                {
                    
                var Ycoin:YCoin = new YCoin();
                Ycoin.x = Math.random() * stage.stageWidth;
                Ycoin.y = Math.random() * stage.stageHeight;
                addChild(Ycoin);
                coinsOnstage.push(Ycoin);
                }
            }

```

This function creates 10 instances of my YCoin and places it around the stage. But i wish the coins to only fall in specific areas, (i.e. i have 8 green rectangles, names area1,area2 etc) because the idea is you have to collect the coins but only staying on the green rectangles.

i knows its the stage.stageWidth i need to change but i cant think what to change it too!?  
Please Help

Thanks 😃
