Packagepegas.draw
Classpublic dynamic class GearPen
InheritanceGearPen Inheritance Pen Inheritance flash.utils.Proxy

This pen drawing gears.

Example :

     import pegas.draw.Align ;
     import pegas.draw.GearPen ;
     import pegas.draw.FillStyle ;
     
     stage.scaleMode = StageScaleMode.NO_SCALE ;
     stage.align = "" ;
     
     var shape:Shape = new Shape() ;
     shape.x = 740 / 2 ;
     shape.y = 420 / 2 ;
     
     var pen:GearPen = new GearPen( shape.graphics ) ;
     pen.align = Align.CENTER ;
     pen.fill  = new FillStyle( 0xEBD936 , 1 ) ;
     
     pen.draw() ;
     addChild( shape ) ;
     
     var keyDown:Function = function( e:KeyboardEvent ):void
     {
         var code:uint = e.keyCode ;
         switch( code )
         {
             case Keyboard.LEFT :
             {
                 pen.draw( 0, 0, 6, 150, 70 , 0, 5, 40, Align.LEFT ) ;
                 break ;
             }
             case Keyboard.RIGHT :
             {
                 pen.draw( 0, 0, 5, 80, 40 , 0, 5, 10, Align.RIGHT ) ;
                 break ;
             }
             case Keyboard.UP :
             {
                 pen.draw( 0, 0, 8, 100, 40 , 0 ,  5, 5, Align.TOP ) ;
                 break ;
             }
             case Keyboard.DOWN :
             {
                 pen.draw( 0, 0, 10 , 100, 60 , 0, 30, 5, Align.BOTTOM ) ;
                 break ;
             }
             case Keyboard.SPACE :
             {
                 pen.x = 10 ;
                 pen.y = 40 ;
                 pen.sides  = 8  ;
                 pen.holeRadius  = 40 ;
                 pen.holeSides   = 6 ;
                 pen.innerRadius = 120 ;
                 pen.outerRadius = 80 ;
                 pen.angle  = 40 ;
                 pen.align  = Align.TOP_RIGHT ;
                 pen.draw() ;
                 break ;
             }
         }
     }
     
     var enterFrame:Function = function( e:Event ):void
     {
         pen.angle += 15 ;
         pen.draw() ;
     }
     
     var mouseDown:Function = function( e:MouseEvent ):void
     {
         stage.addEventListener( Event.ENTER_FRAME , enterFrame ) ;
     }
     
     var mouseUp:Function = function( e:MouseEvent ):void
     {
         stage.removeEventListener( Event.ENTER_FRAME , enterFrame ) ;
     }
     
     stage.addEventListener( MouseEvent.MOUSE_DOWN , mouseDown ) ;
     stage.addEventListener( MouseEvent.MOUSE_UP , mouseUp ) ;
     
     stage.addEventListener( KeyboardEvent.KEY_DOWN , keyDown ) ;
     



Public Properties
 PropertyDefined by
 Inheritedalign : uint
(read-write) Determinates the align value of the pen.
Pen
  angle : Number
Starting angle in degrees (default to 0).
GearPen
 Inheritedfill : IFillStyle
Determinates the fill style object of the pen.
Pen
 Inheritedgraphics : Graphics
Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur.
Pen
  holeRadius : Number
The size of hole.
GearPen
  holeSides : Number
Draw a polygonal hole with this many sides (must be > 2)
GearPen
  innerRadius : Number
The radius of the indent of the teeth.
GearPen
 Inheritedline : ILineStyle
Determinates the line style object of the pen.
Pen
  outerRadius : Number
The outer radius of the teeth.
GearPen
  sides : uint
The number of points of the star.
GearPen
 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.
GearPen
  y : Number
The offset y value of the center of the circle.
GearPen
Public Methods
 MethodDefined by
  
GearPen(graphic:*, x:Number = 0, y:Number = 0, points:uint = 5, innerRadius:Number = 30, outerRadius:Number = 40, angle:Number = 0, holeSides:Number = 3, holeRadius:Number, align:uint = 10)
Creates a new StarPen instance.
GearPen
 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
Draws the shape.
GearPen
  
drawShape():void
This method contains the basic drawing shape algorithm.
GearPen
 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.
GearPen
 Inherited
toString():String
Returns the string representation of this object.
Pen
Protected Methods
 MethodDefined by
 Inherited
callProperty(methodName:*, ... rest):*
Overrides the behavior of an object property that can be called as a function.
Pen
Property detail
angleproperty
public var angle:Number

Starting angle in degrees (default to 0).

holeRadiusproperty 
public var holeRadius:Number

The size of hole.

holeSidesproperty 
public var holeSides:Number

Draw a polygonal hole with this many sides (must be > 2)

innerRadiusproperty 
public var innerRadius:Number

The radius of the indent of the teeth.

outerRadiusproperty 
public var outerRadius:Number

The outer radius of the teeth.

sidesproperty 
sides:uint  [read-write]

The number of points of the star. This value is always > 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
GearPen()constructor
public function GearPen(graphic:*, x:Number = 0, y:Number = 0, points:uint = 5, innerRadius:Number = 30, outerRadius:Number = 40, angle:Number = 0, holeSides:Number = 3, holeRadius:Number, align:uint = 10)

Creates a new StarPen instance.

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).
 
points:uint (default = 5) — (optional) The number of teeth on gear. (must be > 2)
 
innerRadius:Number (default = 30) — (optional) The radius of the indent of the teeth.
 
outerRadius:Number (default = 40) — (optional) The outer radius of the teeth.
 
angle:Number (default = 0) — (optional) The starting angle in degrees. (defaults to 0)
 
holeSides:Number (default = 3) — (optional) draw a polygonal hole with this many sides (must be > 2)
 
holeRadius:Number — (optional) size of hole. Default = innerRadius/3.
 
align:uint (default = 10) — (optional) The Align value to align the shape.
Method detail
draw()method
public override 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 
public override 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).