What are you trying to do -- shift each point by one in the x axis? You need to reference the property on the right hand side of the assignment as well.
for(var b = 0; b < wallPoints.length; b++)
{
wallPoints[b].xPos = wallPoints[b].xPos - 1;
}
or do you want to propagate the x axis from one point to another
for(var b = 1; b < wallPoints.length; b++)
{
wallPoints[b].xPos = wallPoints[b-1].xPos;
}
In the latter case, you'll need to figure out what to do with the first point. Note the change in the termination condition (and start condition in the second case).
EDIT: Here's my test code:
<html>
<head>
<title>Point</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var wallPoints = new Array();
wallPoints[0] = new Point(0,10);
wallPoints[1] = new Point(600,10);
wallPoints[2] = new Point(650,10);
var content = $('#content');
content.append('<h2>Before</h2>');
for(var b = 0; b < wallPoints.length; b++)
{
content.append('<p> x = ' + wallPoints[b].xPos + ', y = ' + wallPoints[b].yPos + '</p>' );
wallPoints[b].xPos = wallPoints[b].xPos-1;
}
content.append('<h2>After</h2>');
for(var b = 0; b < wallPoints.length; b++)
{
content.append('<p> x = ' + wallPoints[b].xPos + ', y = ' + wallPoints[b].yPos + '</p>' );
}
function Point(x,y)
{
this.xPos = x;
this.yPos = y;
}
});
</script>
</head>
<body>
<div id="content">
</div>
</body>
</html>
wallPoints[b].xPos = wallPoints[b]-1;wallPointsplease.var wallPoints = [new Point(0,10), new Point(600,10), new Point(650,10)];