# Actionscript draw dynamic lines

**URL:** <https://forum.kirupa.com/t/actionscript-draw-dynamic-lines/219392>\
**Category:** flash\
**Created:** [March 16, 2007, 5:01am UTC](https://forum.kirupa.com/t/actionscript-draw-dynamic-lines/219392 "2007-03-16T05:01:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![raistie](https://avatars.discourse-cdn.com/v4/letter/r/58f4c7/32.png) [@raistie](https://forum.kirupa.com/u/raistie)\
**Post date:** [March 16, 2007, 5:01am UTC](https://forum.kirupa.com/t/actionscript-draw-dynamic-lines/219392/1 "2007-03-16T05:01:06Z")

</div>

Hi i am currently trying to use actionscript to make a flash  
program so that when i click once to set a circle and click another  
place to set another circle, a line will join these two circles.

If i click to set a 3rd circle then this 3rd circle will line to the 2nd one  
and so on…

i have a circle movie clip in my library and the circles are appearing fine.  
my code is as follows but no line is appearing between the circles…can anyone help me?

\_root.onMouseDown = function() {  
var nc = getNextHighestDepth();  
this.createEmptyMovieClip(“line”, nc);  
nc++;  
this.attachMovie(“circle”, “circle”+nc, nc);  
this[“circle”+nc].\_x = \_xmouse;  
this[“circle”+nc].\_y = \_ymouse;  
if (nc-2 \> 0) {  
line.lineStyle(1, 0x000000);  
gox=this[“circle”+(nc-2)].\_x;  
goy=this[“circle”+(nc-2)].\_y;  
line.moveTo(gox, goy);  
line.lineTo(\_xmouse, \_ymouse);  
}  
};
