ProblemYou want to draw a curve using ActionScript. SolutionUse the Graphics.curveTo( ) method. DiscussionOnce you have set a line style, you can draw a curve using the curveTo( ) method. The curveTo( ) method draws an approximation of a Bezier curve (although optimized for performance), which requires three points: a starting point, a control point, and a destination point:
Figure 7-1. The control point of a curveThe curveTo( ) method requires four parameters. The first two parameters specify the X and Y coordinates of the control point; the next two parameters specify the X and Y coordinates of the destination point. The following example draws a curve with a control point at 0,100 and a destination point at 100,100: sampleSprite.graphics.lineStyle( ); sampleSprite.graphics.curveTo(0, 100, 100, 100); |