Packagegraphics.drawing
Classpublic class HexagonPen
InheritanceHexagonPen Inheritance Pen Inheritance flash.utils.Proxy

This pen is the tool to draw an hexagon vector shape.

Example :

     package examples 
     {
         import graphics.Align;
         import graphics.FillStyle;
         import graphics.drawing.HexagonPen;
         
         import flash.display.Shape;
         import flash.display.Sprite;
         import flash.display.StageScaleMode;
         import flash.events.Event;
         import flash.events.KeyboardEvent;
         import flash.events.MouseEvent;
         import flash.ui.Keyboard;
              public class HexagonPenExample extends Sprite 
         {
             public function HexagonPenExample()
             {
                 ///////////
                 
                 shape   = new Shape() ;
                 shape.x = 740 / 2 ;
                 shape.y = 420 / 2 ;
                 
                 pen      = new HexagonPen( shape , 0, 0, 40, 45, Align.TOP_RIGHT ) ;
                 pen.fill = new FillStyle( 0xFF0000 , 0.6 ) ;
                 pen.draw() ;
                 
                 addChild( shape ) ;
                 
                 ///////////
     
                 stage.scaleMode = StageScaleMode.NO_SCALE ;
                 stage.addEventListener( KeyboardEvent.KEY_DOWN , keyDown   ) ;
                 stage.addEventListener( MouseEvent.MOUSE_DOWN  , mouseDown ) ;
                 stage.addEventListener( MouseEvent.MOUSE_UP    , mouseUp   ) ;
             }
             
             public var pen:HexagonPen ;
             public var shape:Shape ;
             
             public function enterFrame( e:Event ):void
             {
                 pen.angle += 15 ;
                 pen.draw() ;
             }
             
             public function keyDown( e:KeyboardEvent ):void
             {
                 var code:uint = e.keyCode ;
                 switch( code )
                 {
                     case Keyboard.LEFT :
                     {
                         pen.draw( 0, 0, 40, 0, Align.LEFT ) ;
                         break ;
                     }
                     case Keyboard.RIGHT :
                     {
                         pen.draw( 0, 0, 40, 0, Align.RIGHT ) ;
                         break ;
                     }
                     case Keyboard.UP :
                     {
                         pen.draw( 0, 0, 40, 0, Align.TOP ) ;
                         break ;
                     }
                     case Keyboard.DOWN :
                     {
                         pen.useApothem = true ;
                         pen.draw( 0, 0, 40, 0, Align.BOTTOM ) ;
                         pen.useApothem = false ;
                         break ;
                     }
                     case Keyboard.SPACE :
                     {
                         pen.draw( 0, 0, 40, 0, Align.CENTER ) ;
                         break ;
                     }
                 }
             }
             
             public function mouseDown( e:MouseEvent ):void
             {
                 stage.addEventListener( Event.ENTER_FRAME , enterFrame ) ;
             }
             
             public function mouseUp( e:MouseEvent ):void
             {
                 stage.removeEventListener( Event.ENTER_FRAME , enterFrame ) ;
             }
         }
     }
     



Public Properties
 PropertyDefined By
 Inheritedalign : uint
Determinates the align value of the pen.
Pen
  angle : Number
Starting angle in degrees to draw the shape and defines the position of all the vertices (default to 0).
HexagonPen
  apothem : Number
Determinates the size of the line segment from the center of a regular polygon to the midpoint of a side.
HexagonPen
 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
  height : Number
The height of the hexagon.
HexagonPen
 Inheritedline : ILineStyle
Determinates the line style object of the pen.
Pen
  radius : Number
The radius size of the hexagon.
HexagonPen
  useApothem : Boolean
Indicates if the pen use the apothem of the hexagon to draw the shape or the radius (to defines the y position).
HexagonPen
 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
  width : Number
The width of the hexagon.
HexagonPen
  x : Number
The offset x value of the center of the circle.
HexagonPen
  y : Number
The offset y value of the center of the circle.
HexagonPen
Public Methods
 MethodDefined By
  
HexagonPen(graphic:*, x:Number = 0, y:Number = 0, radius:Number = 40, angle:Number = 0, align:uint = 10)
The Pen class use composition to control a Graphics reference and draw custom vector graphic shapes.
HexagonPen
 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.
HexagonPen
  
drawShape():void
[override] This method contains the basic drawing shape algorithm.
HexagonPen
 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(x:Number = 0, y:Number = 0, radius:Number = 40, angle:Number = 0, align:uint = 10):void
Sets the pen properties.
HexagonPen
Property Detail
angleproperty
angle:Number

Starting angle in degrees to draw the shape and defines the position of all the vertices (default to 0).


Implementation
    public function get angle():Number
    public function set angle(value:Number):void
apothemproperty 
apothem:Number

Determinates the size of the line segment from the center of a regular polygon to the midpoint of a side.


Implementation
    public function get apothem():Number
    public function set apothem(value:Number):void
heightproperty 
height:Number

The height of the hexagon.


Implementation
    public function get height():Number
    public function set height(value:Number):void
radiusproperty 
radius:Number

The radius size of the hexagon.


Implementation
    public function get radius():Number
    public function set radius(value:Number):void
useApothemproperty 
public var useApothem:Boolean

Indicates if the pen use the apothem of the hexagon to draw the shape or the radius (to defines the y position).

widthproperty 
width:Number

The width of the hexagon.


Implementation
    public function get width():Number
    public function set width(value:Number):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
HexagonPen()Constructor
public function HexagonPen(graphic:*, x:Number = 0, y:Number = 0, radius:Number = 40, angle:Number = 0, align:uint = 10)

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) — The x location of the center of the shape relative to the registration point of the parent display object (in pixels).
 
y:Number (default = 0) — The y location of the center of the circle relative to the registration point of the parent display object (in pixels).
 
radius:Number (default = 40) — The radius size of the hexagon (in pixels).
 
angle:Number (default = 0) — (optional) The starting angle in degrees. (defaults to 0)
 
align:uint (default = 10) — The alignement value to align the shape, by default use the Align.TOP_LEFT value (10).
Method Detail
draw()method
override public function draw(... arguments):void

Draws the shape.

Parameters

... arguments — The x location of the center of the shape 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(x:Number = 0, y:Number = 0, radius:Number = 40, angle:Number = 0, align:uint = 10):void

Sets the pen properties.

Parameters

x:Number (default = 0) — The x location of the center of the shape relative to the registration point of the parent display object (in pixels).
 
y:Number (default = 0) — The y location of the center of the circle relative to the registration point of the parent display object (in pixels).
 
radius:Number (default = 40) — The radius size of the hexagon (in pixels).
 
angle:Number (default = 0) — (optional) The starting angle in degrees. (defaults to 0)
 
align:uint (default = 10) — The alignement value to align the shape, by default use the Align.TOP_LEFT value (10).