views:

41

answers:

4

Okay so basically I want to draw a circle in as3 that has a 'hole' in it (like a donut). Something like this, but without the outlines:

http://www.steel.ie/DugganSteel/Pictures/Hollow-circle.gif

This doesn't work:

SPRITE.graphics.beginFill(0xFFFFFF);
SPRITE.graphics.drawCircle(0,0,10);
SPRITE.graphics.endFill();
SPRITE.graphics.drawCircle(0,0,5);

I mean this seems like it'd be simple but I can't find any information on it. I should also mention that I'm trying to only draw 3/4 of the circle, like 3/4 of donut. So I was planning on drawing a transparent circle and square over the original circle, I know this seems kinda of weird since you'd expect something transparent to show whats underneath it.

+1  A: 

You can just make the line thickness the desired donut width and avoid using beginFill set graphics.lineStyle To make it only go 3/4 of the way around you could use curveTo to draw the 3 quarters.

danjp
+1  A: 

Hi there,

Its actually really simple. See the following code:

var p:Point = new Point(100, 100);
graphics.beginFill(0xFF0000);
graphics.drawCircle(p.x, p.y, 100);
graphics.drawCircle(p.x, p.y, 50);

Intersections cancel each other out until you call endFill

Goodluck!

Tyler Egeto
only thing I don't understand is, why do intersections cancel each other?
dta
I found a useful link : http://www.senocular.com/flash/tutorials/flash10drawingapi/
dta
That's a good read, it focuses on the new drawing API though, so watch out for that!
Tyler Egeto
A: 

The above method by Tyler works, however if an easier way to do it is to simply begin drawing the inner circle first. Basically Flash doesn't actually fill in the color until you call endFill() (again as mentioned by Tyler), so you start drawing on the inner circle, then the outer circle then on endFill() Flash fills in the gap.

SPRITE.graphics.beginFill(0xFFFFFF);
SPRITE.graphics.drawCircle(0,0,5);
SPRITE.graphics.drawCircle(0,0,10);
SPRITE.graphics.endFill();

Hope this clears things up for you.

I don't see what's easier about this, you just flipped two lines around. Its exactly the same thing, you draw two shapes and they are intersected leaving the result.
Tyler Egeto
Yeah your right, shouldn't have used the word easier. There the same
A: 

Introduction to Flash drawing API, will help you understand a bit more :

http://www.senocular.com/flash/tutorials/flash10drawingapi/

dta