Drawing Lines Between Objects Stored In Array

Basically I am completely stuck…:puzzled:

I’m trying to draw a line between circles stored in an array. I have a button on the stage which adds another circle to the stage. My issue is I cannot draw a line between the most recent circle added to the array and the one that will be added next.

It is a bit complicated and I’m not an experienced programmer by any stretch of the imagination.:emb:

Anyway, here’s my code:

var pointArray:Array = new Array()
var currentPoint:Number = pointArray.length
var thePoint:MovieClip = new drawPoint() 
addChild(thePoint)
pointArray.push(thePoint)
thePoint.x = stage.stageWidth/2
thePoint.y = stage.stageHeight/2
thePoint.addEventListener(MouseEvent.MOUSE_DOWN, beginDrag)
thePoint.addEventListener(MouseEvent.MOUSE_UP, endDrag)
thePoint.addEventListener(Event.ENTER_FRAME, drawShapes)
addPointButton.addEventListener(MouseEvent.MOUSE_UP, addPoint)
function addPoint(event:MouseEvent):void{
 
 var thePoint:MovieClip = new drawPoint()
 addChild(thePoint)
 pointArray.push(thePoint)
 thePoint.x = stage.stageWidth/2
 thePoint.y = stage.stageHeight/2
 thePoint.addEventListener(MouseEvent.MOUSE_DOWN, beginDrag)
 thePoint.addEventListener(MouseEvent.MOUSE_UP, endDrag)
 thePoint.addEventListener(Event.ENTER_FRAME, drawShapes)
}

function beginDrag(event:MouseEvent):void{
 event.target.startDrag()
}
function endDrag(event:MouseEvent):void{
 event.target.stopDrag()
}
function drawShapes(event:Event):void{
 for (var i =0; i < pointArray.length; i++){
  var shape:Sprite = new Sprite()
  addChild(shape)
  shape.graphics.beginFill(0x000000)
  shape.graphics.moveTo(pointArray[currentPoint].x, pointArray[currentPoint - 1].y)
  shape.graphics.lineTo(pointArray[currentPoint].x, pointArray[currentPoint].y)
  
 }
}

Currently I am getting a TypeError: Error# 1010.

Thankyou in advance.

CCG1993.