# Drawing Lines

**URL:** <https://forum.kirupa.com/t/drawing-lines/19177>\
**Category:** Uncategorized\
**Created:** [April 25, 2003, 12:54am UTC](https://forum.kirupa.com/t/drawing-lines/19177 "2003-04-25T00:54:09Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![session9](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@session9](https://forum.kirupa.com/u/session9)\
**Post date:** [April 25, 2003, 12:54am UTC](https://forum.kirupa.com/t/drawing-lines/19177/1 "2003-04-25T00:54:09Z")

</div>

Hey I was wondering. Say I made 2 circles that were draggable, how would i make it so a line would stay connected to both circles at all times? Ok thanks!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 25, 2003, 12:59am UTC](https://forum.kirupa.com/t/drawing-lines/19177/2 "2003-04-25T00:59:57Z")

</div>

assuming that the instances of the circles are circleA and circleB…

```auto
this.createEmptyMovieClip("line", -1);
line.onEnterFrame = function() {
this.clear();
this.lineStyle(1, 0, 100);
this.moveTo(circleA._x, circleA._y);
this.lineTo(circleB._x, circleB._y);
};

```

just paste the script and change the instance names if needed. =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 25, 2003, 5:50pm UTC](https://forum.kirupa.com/t/drawing-lines/19177/3 "2003-04-25T17:50:34Z")

</div>

Hey thanks! Im at school right now, but I’ll give that a try as soon as i get home! Thanks again!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 25, 2003, 5:53pm UTC](https://forum.kirupa.com/t/drawing-lines/19177/4 "2003-04-25T17:53:46Z")

</div>

kax: You should do line.onMouseMove instead of line.onEnterFrame. Since the clips are just draggable the only time they will move is when the mouse moves, so why keep an onEnterFrame running when there is no need?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 25, 2003, 5:54pm UTC](https://forum.kirupa.com/t/drawing-lines/19177/5 "2003-04-25T17:54:26Z")

</div>

ok… let me know if you have any problems. 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 25, 2003, 5:56pm UTC](https://forum.kirupa.com/t/drawing-lines/19177/6 "2003-04-25T17:56:26Z")

</div>

😛

good point, lost. honestly i didn’t read the whole post… i just took a quick look and replied. 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 25, 2003, 5:58pm UTC](https://forum.kirupa.com/t/drawing-lines/19177/7 "2003-04-25T17:58:45Z")

</div>

Well either way, they both work 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 25, 2003, 6:05pm UTC](https://forum.kirupa.com/t/drawing-lines/19177/8 "2003-04-25T18:05:44Z")

</div>

WOW!!! so easy!!!

the method i learned a while back was so complicated i gave up on trying to remember how it was done…

now i can think about this again 🙂

👽

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 25, 2003, 6:06pm UTC](https://forum.kirupa.com/t/drawing-lines/19177/9 "2003-04-25T18:06:45Z")

</div>

yup. :beam:

revenge?? 😛  
[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=20960](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=20960)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 25, 2003, 6:08pm UTC](https://forum.kirupa.com/t/drawing-lines/19177/10 "2003-04-25T18:08:41Z")

</div>

> _Originally posted by markcq_  
> \*\*WOW!!! so easy!!!

the method i learned a while back was so complicated i gave up on trying to remember how it was done…

now i can think about this again 🙂

👽\*\*

now you know… there’s always an easier way. :beam: 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 25, 2003, 6:18pm UTC](https://forum.kirupa.com/t/drawing-lines/19177/11 "2003-04-25T18:18:59Z")

</div>

ok, i’ve taken this line thing further…

i added the script below to each instance of the circle (now the circles will run away from the mouse)

problem is that some times the circles move too fast for the line… any suggestions?

onClipEvent(load){  
homeX = this.\_x  
homeY = this.\_y  
magnet = 1000  
}  
onClipEvent(enterFrame){  
x0 = this.\_x   
y0 = this.\_y  
x1 = \_root.\_xmouse  
y1 = \_root.\_ymouse

```
distancex = x1-x0
distancey = y1-y0

distance = Math.sqrt((distancex * distancex) + (distancey * distancey))

powerx = this._x - (distancex / distance) * magnet / distance
powery = this._y - (distancey / distance) * magnet / distance

forcex = (forcex + (homex - x0) / 2) / 1.66
forcey = (forcey + (homey - y0) / 2) / 1.66

this._x = powerx + forcex
this._y = powery + forcey

```

}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 25, 2003, 8:40pm UTC](https://forum.kirupa.com/t/drawing-lines/19177/12 "2003-04-25T20:40:37Z")

</div>

> \*Originally posted by kax \*  
> \*\*yup. :beam:

revenge?? 😛  
[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=20960](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=20960) \*\*

Actually not intentionally… but sure… you could call it that :P…lol :evil:

j/k, it wasn’t revenge, because revenge is getting someone back who has wronged you, and well… you didn’t wrong me… you corrected my wrong 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 26, 2003, 1:41am UTC](https://forum.kirupa.com/t/drawing-lines/19177/13 "2003-04-26T01:41:55Z")

</div>

got it right!!! 😛

this is a variation on the theme… it works though. hehehe

👽

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 26, 2003, 2:58am UTC](https://forum.kirupa.com/t/drawing-lines/19177/14 "2003-04-26T02:58:46Z")

</div>

I feel like a cat… playing with a spring… 😛

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 26, 2003, 3:06am UTC](https://forum.kirupa.com/t/drawing-lines/19177/15 "2003-04-26T03:06:20Z")

</div>

meaow! :evil: (hey, just imagine this is a cat icon) hehehe…

i like the small things… you know what they say about small things and small minds…
