Recipe 7.11. Drawing a Star


Problem

You want to draw a star.

Solution

Use the Pen.drawStar( ) method.

Discussion

The Pen.drawStar( ) method enables you to quickly draw a star shape programmatically. The method accepts the following parameters:


x

The x coordinate of the center of the star.


y

The y coordinate of the center of the star.


points

The number of points on the star.


innerRadius

The radius of the inner part of the star.


outerRadius

The radius of the outer part of the star.


rotation

The default value is 0; you can specify a rotation in degrees.

The following example draws a five-pointed star:

var pen:Pen = new Pen(sampleSprite.graphics); pen.drawStar(100, 100, 5, 50, 100);




ActionScript 3. 0 Cookbook
ActionScript 3.0 Cookbook: Solutions for Flash Platform and Flex Application Developers
ISBN: 0596526954
EAN: 2147483647
Year: 2007
Pages: 351

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net