Generate the elements within the screen

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 < 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.