# Generate the elements within the screen

**URL:** <https://forum.kirupa.com/t/generate-the-elements-within-the-screen/321120>\
**Category:** Uncategorized\
**Created:** [April 11, 2011, 12:50pm UTC](https://forum.kirupa.com/t/generate-the-elements-within-the-screen/321120 "2011-04-11T12:50:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flangofas](https://avatars.discourse-cdn.com/v4/letter/f/f04885/32.png) [@flangofas](https://forum.kirupa.com/u/flangofas)\
**Post date:** [April 11, 2011, 12:50pm UTC](https://forum.kirupa.com/t/generate-the-elements-within-the-screen/321120/1 "2011-04-11T12:50:00Z")

</div>

hey guys

I try to use the following code to add elements in a screen . I try to bound the elements within the screen’s dimensions but I can’t because either the screen size reduces or they are out of bounds. How can I generate the elements within the screen without affection on the screen’s size?

```
var screen:Mask = new Mask(); 

screen.y = 107;
screen.x = 76;

screen.width=832;
screen.height=530;

for (var i = 0; i &lt; 10; i++) {
    
    var test:Test = new Test();
    test.x = Math.random() * 832;
    
    test.y = Math.random() * 530;
    
    trace("height"+screen.height);
    
    screen.addChild(test);
    
    //screen.height=530; 

}
    addChild(screen);

```

OUTPUT

height530  
height530  
height530  
height917.2  
height917.2  
height917.2  
height917.2  
height917.2  
height917.2  
height917.2

it doesn’t make sense to me why the height changes and the width remains the same.

i am new at AS3 so i will greatly appreciate your feedback thanks in advance.
