I have drawn a series of lines using flash’s graphics.lineTo command, and placed them in an array to be referenced later. Based on certain user interactions, the clips that hold these lines can be shifted to the right, causing the lines to move with them, no longer connecting to the point they originally connected to. So I need to extend the lines by the amount their parent clip was shifted (I’ve called this incVal). So what I need to do is find the point at which each of these lines ended at, and draw from that point to the left by incVal. How do I get that ending point of the line?
This is my code:
To draw line and add it both to the clip and to an array for future reference:
line.graphics.lineTo(localPoint.x,localPoint.y-10);
membersRef.addChild(line);
parallelArr.push(line);
To reference the line later by looping through the array:
function extendParallels(incVal):void {
for (var i=0;i<parallelArr.length;i++){
trace (parallelArr[i]);
//need to extend line with code here.
}
}
You can’t get the graphical endpoints exactly from the sprite in an easy way. You should consider to save the end point in a variable.
And in
parallelArryou could save an object which holds a reference to this point and to the DisplayObject where your line is drawn on.