0
votes

i'm trying to make something for a game i'm making. When someone clicks on the movieclip i want it to draw an inner circle and an outer circle. I'd like to fill between the circles with a opaque colour (purple in the image) so people can see basically a large thick circle around the movieclip but not touching the movieclip. I then need to check if the mouseclick happens between the two circles only.

The image below shows what i mean. The thing is the thickness of the purple bit has to be adjustable (not in game as such), if you click on 1 movieclip the thickness of the purple bit may be 10pixels, a different clip may be 50. Obviously checking for a click greater than inner circle x and less than outer circle only works on a straight line across from the clip, once you move up or down this doesn't work so well. Any help is much appreciated as i can't seem to work this out. I've tried drawing 2 circles and also tried using 2 movieclip circles but can't get it to work.

Seems i cant upload pictures on here. Easiest way is to think of a no entry sign without the / line going through the middle. The centre is the movieclip, the inside part of the red circle the inner circle and the outer is the outer circle but at no point does the red touch the movieclip

1
You can upload pictures by 1st: Making a PhotoBucket account here 2nd: Upload your picture to your account on their, and Photobucket then lets you get a link to your picture 3rd: edit you question and follow the image inserting instruction that you can get by clicking the image button above your editing box. Also: can you try to describe your problem a little more, I am having trouble understanding your exact question. - Xiler
Are you having trouble getting the circles to display how you want, or just detecting the click area? Or both? - Cadin

1 Answers

2
votes

I would measure the distance from the center of the circles to the mouse click point. Then you just need to check is that distance greater than the inner circle radius and less than the outer circle radius.

Something along these lines:

var clickPoint:Point = new Point(mouseX, mouseY);
var centerPoint:Point = new Point(circleMC.x circleMC.y);
var dist:Number = Point.distance(clickPoint, centerPoint);

if(dist > innerRadius && dist < outerRadius){
    trace("the click happened between circles
}