Packagegraphics.drawing
Classpublic dynamic class PolygonPen
InheritancePolygonPen Inheritance Pen Inheritance flash.utils.Proxy

This pen is the tool to draw a regular polygon vector shape.

Example :

     package examples 
     {
         import graphics.Align;
         import graphics.FillStyle;
         import graphics.drawing.PolygonPen;
          
         import flash.display.Shape;
         import flash.display.Sprite;
         import flash.display.StageScaleMode;
         import flash.events.KeyboardEvent;
         import flash.ui.Keyboard;
         
         public class ExamplePolygonPen extends Sprite 
         {
             public function ExamplePolygonPen()
             {
                 stage.scaleMode = StageScaleMode.NO_SCALE ;
                 stage.align     = "" ;
                 
                 var shape:Shape = new Shape() ;
                 shape.x = 740 / 2 ;
                 shape.y = 420 / 2 ;
                 
                 pen      = new PolygonPen( shape , 0, 0, 10 , 100, 0 , Align.CENTER ) ;
                 pen.fill = new FillStyle( 0xEBD936 ) ;
                 
                 pen.draw() ;
                 
                 addChild( shape ) ;
                 
                 stage.addEventListener( KeyboardEvent.KEY_DOWN , keyDown ) ;
             }
             
             public var pen:PolygonPen ;
             
             public function keyDown( e:KeyboardEvent ):void
             {
                 var code:uint = e.keyCode ;
                 switch( code )
                 {
                     case Keyboard.LEFT :
                     {
                         pen.draw( 0, 0, 10 , 100, 0 , Align.LEFT ) ;
                         break ;
                     }
                     case Keyboard.RIGHT :
                     {
                         pen.draw( 0, 0, 10 , 100, 20 , Align.RIGHT ) ;
                         break ;
                     }
                     case Keyboard.UP :
                     {
                         pen.draw( 0, 0, 3 , 100, 40 , Align.TOP ) ;
                         break ;
                     }
                     case Keyboard.DOWN :
                     {
                         pen.draw( 0, 0, 4 , 100, 60 , Align.BOTTOM ) ;
                         break ;
                     }
                     case Keyboard.SPACE :
                     {
                         pen.x      = 10 ;
                         pen.y      = 40 ;
                         pen.sides  = 8  ;
                         pen.radius = 50 ;
                         pen.angle  = 40 ;
                         pen.align  = Align.TOP_RIGHT ;
                         pen.draw() ;
                         break ;
                     }
                 }
             }
         }
     }
     



Public Properties
 PropertyDefined By
 Inheritedalign : uint
Determinates the align value of the pen.
Pen
  angle : Number = 0
Starting angle in degrees (default to 0).
PolygonPen
 Inheritedfill : IFillStyle
Determinates the fill style object of the pen.
Pen
 Inheritedgraphics : *
Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur.
Pen
 Inheritedline : ILineStyle
Determinates the line style object of the pen.
Pen
  radius : Number
The radius value of the pen.
PolygonPen
  sides : uint
The number of sides (Math.abs(sides) must be > 2)
PolygonPen
 InheriteduseClear : Boolean = true
Indicates if the clear() method is invoked at the end of the draw method.
Pen
 InheriteduseEndFill : Boolean = true
Indicates if the endFill() method is invoked at the end of the draw method.
Pen
  x : Number
The offset x value of the center of the circle.
PolygonPen
  y : Number
The offset y value of the center of the circle.
PolygonPen
Public Methods
 MethodDefined By
  
PolygonPen(graphic:*, x:Number = 0, y:Number = 0, sides:uint = 6, radius:Number = 20, angle:Number = 0, align:uint = 1)
Creates a new PolygonPen.
PolygonPen
 Inherited
BF(... arguments):void
Defines a shortcut reference to used the beginBitmapFill method.
Pen
 Inherited
C(... arguments):void
Defines a shortcut reference to used the curveTo method.
Pen
 Inherited
CL():void
Defines a shortcut reference to used the clear method.
Pen
  
draw(... arguments):void
[override] Draws the shape.
PolygonPen
  
drawShape():void
[override] This method contains the basic drawing shape algorithm.
PolygonPen
 Inherited
EF():void
Defines a shortcut reference to used the endFill method.
Pen
 Inherited
F(... arguments):void
Defines a shortcut reference to used the beginFill method.
Pen
 Inherited
GF(... arguments):void
Defines a shortcut reference to used the beginGradientFill method.
Pen
 Inherited
GS(... arguments):void
Defines a shortcut reference to used the lineGradientStyle method.
Pen
 Inherited
L(... arguments):void
Defines a shortcut reference to used the lineTo method.
Pen
 Inherited
M(... arguments):void
Defines a shortcut reference to used the moveTo method.
Pen
 Inherited
S(... arguments):void
Defines a shortcut reference to used the lineStyle method.
Pen
  
setPen(... arguments):void
Sets the shape options to defined all values to draw the shape.
PolygonPen
Property Detail
angleproperty
public var angle:Number = 0

Starting angle in degrees (default to 0).

radiusproperty 
public var radius:Number

The radius value of the pen.

sidesproperty 
sides:uint

The number of sides (Math.abs(sides) must be > 2)


Implementation
    public function get sides():uint
    public function set sides(value:uint):void
xproperty 
public var x:Number

The offset x value of the center of the circle.

yproperty 
public var y:Number

The offset y value of the center of the circle.

Constructor Detail
PolygonPen()Constructor
public function PolygonPen(graphic:*, x:Number = 0, y:Number = 0, sides:uint = 6, radius:Number = 20, angle:Number = 0, align:uint = 1)

Creates a new PolygonPen. The Pen class use composition to control a Graphics reference and draw custom vector graphic shapes.

Parameters
graphic:* — The Graphics reference to control with this helper. You can passed-in a Shape or Sprite/MovieClip reference in argument.
 
x:Number (default = 0) — (optional)The x location of the center of the circle relative to the registration point of the parent display object (in pixels).
 
y:Number (default = 0) — (optional)The y location of the center of the circle relative to the registration point of the parent display object (in pixels).
 
sides:uint (default = 6) — (optional) The number of sides (Math.abs(sides) must be > 2)
 
radius:Number (default = 20) — (optional) The radius of the circle (in pixels).
 
angle:Number (default = 0) — (optional) The starting angle in degrees. (defaults to 0)
 
align:uint (default = 1) — (optional) The Align value to align the shape.
Method Detail
draw()method
override public function draw(... arguments):void

Draws the shape.

Parameters

... arguments — (optional)The x location of the center of the circle relative to the registration point of the parent display object (in pixels).

drawShape()method 
override public function drawShape():void

This method contains the basic drawing shape algorithm.

setPen()method 
public function setPen(... arguments):void

Sets the shape options to defined all values to draw the shape.

Parameters

... arguments — (optional) The x location of the center of the circle relative to the registration point of the parent display object (in pixels).