# Help needed with x and y values in array

**URL:** https://forum.kirupa.com/t/help-needed-with-x-and-y-values-in-array/256784
**Category:** Uncategorized
**Created:** [April 7, 2008, 10:22am UTC](https://forum.kirupa.com/t/help-needed-with-x-and-y-values-in-array/256784 "2008-04-07T10:22:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Judah\_Smith](https://avatars.discourse-cdn.com/v4/letter/j/c67d28/32.png) [@Judah\_Smith](https://forum.kirupa.com/u/Judah_Smith)
#### Post date: [April 7, 2008, 10:22am UTC](https://forum.kirupa.com/t/help-needed-with-x-and-y-values-in-array/256784/1 "2008-04-07T10:22:24Z")

</div>

Hello again

In my first stab at a game I have an array called playerBrickArray holding 28 bricks that are 20x50 pixels.

Currently they are all in a line and I am trying to put them in two lines of 14 from top to bottom of the screen.

I have been trying to use a while loop to say when the arrays Y value is greater than the stage height, set x to -20 and y to the top of the screen again. Unfortunately nothing I have tried so far works. I wonder if you can help.

My code is

//playerBrick starting positions  
var playerStartX:Number = 380;  
var playerStartY:Number = 50;

public function setPlayerArray (objPlayer:Object, i:Number)  
{  
playerBrickArray\* = objPlayer;  
playerBrickArray\*.setX(playerStartX);  
playerBrickArray\*.setY(playerStartY\*i);  
}

My idea has been various combinations of the following code to be included in the setPlayerArray function above (not sure if thats the right place for it).

while (playerBrickArray\*.\_y \> Stage.height)  
{  
playerBrickArray\*.\_x (playerStartX-20);  
playerBrickArray\*.\_y = 0;  
}

Trace reveals that all 28 bricks are being made by the array, but only the first row is properly in a line. From the second row onwards they appear on top of each other, and have stopped incrementing by 50.

I’ve included a picture of the problem to help explain it, and a zip of my game so far.

Thanks
