# Array Help (Random Values stated and Called)

**URL:** <https://forum.kirupa.com/t/array-help-random-values-stated-and-called/99345>\
**Category:** Uncategorized\
**Created:** [January 17, 2004, 6:21pm UTC](https://forum.kirupa.com/t/array-help-random-values-stated-and-called/99345 "2004-01-17T18:21:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yeldarb](https://avatars.discourse-cdn.com/v4/letter/y/51bf81/32.png) [@Yeldarb](https://forum.kirupa.com/u/Yeldarb)\
**Post date:** [January 17, 2004, 6:21pm UTC](https://forum.kirupa.com/t/array-help-random-values-stated-and-called/99345/1 "2004-01-17T18:21:14Z")

</div>

I am trying to make a random shape, I want each different point to draw a line to every other point, which I know this won’t do yet even if it worked the way that I wanted. But, at the moment, my code does nothing. It is supposed to draw a line from from the first value in the point array to the second value in it to the third value in it. I can’t figure out what I’m doing wrong, am I declaring it wrong? Calling it wrong? Doing it wrong all together?

Here’s my code:

```auto
onLoad = function() {
	drawIt(10);
}

function drawIt(numberOfPoints) {
	randomPoints(numberOfPoints);
	createEmptyMovieClip(shape, 0);
	shape.lineStyle(3, 000000, 100);
	shape.moveTo(point[x1], point[y1]);
	for(i=0; i<numberOfPoints; i++) {
		shape.lineTo(point["x"+i], point["y"+i]);
	}
}

function randomPoints(numOfPoints) {
	point = new Array();
	drawToNumOfPoints = numOfPoints;
	for (i=0; i<numOfPoints; i++) {
		generateRandoms();
		point["x"+i] = randomX;
		point["y"+i] = randomY;
	}
}

function generateRandoms() {
	randomX = random(stage.width);
	randomY = random(stage.height);
}

```

I have also tried switching the line

```auto
point = new Array();

```

to

```auto
point = new Object();

```

but to no avail.

Thanks for your help. 🙂
