# My circles are sticking

**URL:** <https://forum.kirupa.com/t/my-circles-are-sticking/33747>\
**Category:** Uncategorized\
**Created:** [October 23, 2003, 1:54am UTC](https://forum.kirupa.com/t/my-circles-are-sticking/33747 "2003-10-23T01:54:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zachwlewis](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/zachwlewis/32/350_2.png) [@zachwlewis](https://forum.kirupa.com/u/zachwlewis)\
**Post date:** [October 23, 2003, 1:54am UTC](https://forum.kirupa.com/t/my-circles-are-sticking/33747/1 "2003-10-23T01:54:46Z")

</div>

[http://subtlepen.danwa.net/stuffs/circleBounce.html](http://subtlepen.danwa.net/stuffs/circleBounce.html)  
How do I get the circles to bounce off of each other?:puzzle:

---

<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:** [October 23, 2003, 5:39am UTC](https://forum.kirupa.com/t/my-circles-are-sticking/33747/2 "2003-10-23T05:39:50Z")

</div>

hit test, im not too good with it but that one way

---

<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:** [October 23, 2003, 4:37pm UTC](https://forum.kirupa.com/t/my-circles-are-sticking/33747/3 "2003-10-23T16:37:16Z")

</div>

I can’t really use hitTest because if the are moving at angles to each other, it will see the bounding box and not the circle itself.

---

<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:** [October 23, 2003, 5:22pm UTC](https://forum.kirupa.com/t/my-circles-are-sticking/33747/4 "2003-10-23T17:22:12Z")

</div>

well i did something similar. only i had one ball. i made the boundries be the movie stage size. maybe you can make the boundries of each ball be the \_x or \_y value of the other ball.

---

<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:** [October 23, 2003, 10:28pm UTC](https://forum.kirupa.com/t/my-circles-are-sticking/33747/5 "2003-10-23T22:28:10Z")

</div>

…sounds about right.  
I am using a radius code right now…

onClipEvent (load) {  
speed = -5;  
radius = (this.\_width/2);  
}  
onClipEvent (enterFrame) {  
dx = this.\_x-\_root.circle2.\_x;  
distance = Math.sqrt(dx\*dx);  
this.\_x += speed;  
if (this.\_x\>350 or this.\_x\<50) {  
speed = -speed;  
}  
if (distance\<(this.radius+\_root.circle2.radius)) {   
speed = -speed;

```
}

```

}

---

<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:** [October 23, 2003, 11:14pm UTC](https://forum.kirupa.com/t/my-circles-are-sticking/33747/6 "2003-10-23T23:14:46Z")

</div>

i would post my file but it was done in MX 2004.

here’s the code i used for the top and bottom borders, maybe you can incorperate your other circle to it

```auto

// top and bottom borders
_y = _y + yspeed;
if(_y +_height/2 > bottomedge){
	_y = bottomedge - _height/2;
	yspeed = -yspeed * bounce;
}
if(_y -_height/2 < topedge){
	_y = topedge + _height/2;
	yspeed = -yspeed * bounce;
}

```

hope that helps

---

<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:** [October 23, 2003, 11:32pm UTC](https://forum.kirupa.com/t/my-circles-are-sticking/33747/7 "2003-10-23T23:32:44Z")

</div>

Thank you. I will try.
