ProblemYou want to draw an ellipse (oval) at runtime. SolutionUse the Pen.drawEllipse( ) method. DiscussionAn ellipse is a more abstract form of a circle. Rather than having a single, uniform radius, an ellipse is defined by two radii that intersect at right angles. The two radii are called the major and minor radii, and also sometimes simply the x radius and y radius. Drawing an ellipse is just slightly more complex than drawing a circle. However, unlike circles, the Graphics class has no method for drawing ellipses. Therefore, the simplest way to programmatically create an ellipse is to use one of the methods of the Pen class. The drawEllipse( ) method allows for the following four parameters:
The following code defines a Pen object and then draws an ellipse: var pen:Pen = new Pen(sampleSprite.graphics); pen.drawEllipse(100, 100, 100, 50); |