My circles are sticking

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

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

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.

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.

…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;

}

}

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


// 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

Thank you. I will try.