# Euler type problem with drawing links between a set of points(Mathsy as3 problem)

**URL:** <https://forum.kirupa.com/t/euler-type-problem-with-drawing-links-between-a-set-of-points-mathsy-as3-problem/325001>\
**Category:** programming\
**Created:** [September 20, 2011, 8:58pm UTC](https://forum.kirupa.com/t/euler-type-problem-with-drawing-links-between-a-set-of-points-mathsy-as3-problem/325001 "2011-09-20T20:58:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cermunnos](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@cermunnos](https://forum.kirupa.com/u/cermunnos)\
**Post date:** [September 20, 2011, 8:58pm UTC](https://forum.kirupa.com/t/euler-type-problem-with-drawing-links-between-a-set-of-points-mathsy-as3-problem/325001/1 "2011-09-20T20:58:15Z")

</div>

:p:

Ive a program with a set of points which change in number.

Sometimes the number of points is 1 or 0 or 42 or 12.

The points are contained in an array.

I am trying to have a traceDraw-esque function where when I click a checkbox, a set of lines appear between all the points and a set of numbers appear on the lines midpoints displaying the distance between the points.

My current implementation is crap. See here:

![](http://i53.tinypic.com/2ugeznq.jpg)

```auto

var ptA = new Point(ballArray[0].x, ballArray[0].y);
				
				ptA = gameStage.localToGlobal(ptA);
				_line.graphics.lineStyle(1, 0x8888ff);
				_line.graphics.moveTo(ptA.x, ptA.y);
				
				for (i = 0; i < ballArray.length; i++)
				{
					
					for (j = 0; j < ballArray.length; j++)
					{
						
						labelArray*.alpha = 1;
						labelArray*.move((ballArray*.x + ballArray[j].x) / 2, (ballArray*.y + ballArray[j].y) / 2);
						labelArray*.text = ballArray*.h.toFixed(1);
						
						ptA.x = ballArray[j].x;
						ptA.y = ballArray[j].y;
						
						ptA = gameStage.localToGlobal(ptA);
						
						if (i != j)
						{
							_line.graphics.lineTo(ptA.x, ptA.y);
						}
					}
				}

```

Now how would I do this so each point links to each other point exactly once, and it works when there are only 2 points also?
