thank you very much.. I have a little problem though, your solution uses _xmouse and I need to control the ball with the keyboard. _xmouse and _root.circle._x will give different values even though they are in the same spot. How can i get around this?
thank you very much again. But I do have another addition to this problem and if you could help me out yet again it would be great. Now I need to test for a collision if the ellipse is rotating at one of its focus points (If i remember correctly, i think focus points are the spots on either end of the ellipse?)
I think I'm on the right track, I set the center of the MC to one of the focus points, and then I'm guessing that I have to find the center of the ellipse as its rotating which I did by doing this...
centerx = _x-55*Math.cos(_rotation*(Math.PI/180));
centery = _y-55*Math.sin(_rotation*(Math.PI/180));
but I don't know how to work that in with the other stuff.
My ellipse has its center at 0,0 point. I calculate the x,y value in the coordinate system of ellipse by localToGlobal function, so any x,y values modified by rotation have already been corrected by globalToLocal function.
The other way might be simpler. It does not need complex math. That is : create virtual ellipse manually not by math. And use hitTest to detect collision.
This principle can be applied to detect collision between a circle and any shape.
Below is the fla. I have set the blue virtual ellipse _alpha=30; You can set it _alpha=0 to make it invisible.