Packagegraphics.drawing
Classpublic class PageFlipPen
InheritancePageFlipPen Inheritance Pen Inheritance flash.utils.Proxy
Implements Directionable

This pen computes, generates, and draws a pageflip in a specifig Graphics object with two BitmapData reference (pages).

Map of the page flip algorithm.

      TOP_LEFT(0,0)                        TOP_RIGHT(1,0)
      ---------------------------------------------------
      |  <-------------------PW---------------------->  |
      | ^ Offset(0,0)  x-->                             |
      | |                                               |
      | | y                                             |
      | | |                                             |
      | | |                                             |
      | | V                                             |
      | |              pPoints[]                        |
      | |                                               |
      | |                                               |
      | |                                               |
      | |                                          (T3) |
      | PH                                           ---|
      | |                                         --- /  
      | |                                      ---   /   
      | |                                   ---     /    
      | |                                ---       /     
      | |                             ---         /      
      | |                          ---           /       
      | |                 drag  ---   cPoints[] /        
      | |                         \            /         
      | |                          \          /          
      | |                           \        /           
      | |                            \      /            
      | |                             \    /             
      | V                              \  /              
      |-------------------------------- \/               
      BOTTOM_LEFT(0,1)                  BOTTOM_RIGHT(1,1)
     



Public Properties
 PropertyDefined By
 Inheritedalign : uint
Determinates the align value of the pen.
Pen
  corner : Point
The original position of the dragged point.
PageFlipPen
  direction : String
Indicates the direction value of this object.
PageFlipPen
  drag : Point
Indicates the position of the drag point relative to the upper-left corner.
PageFlipPen
 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
Indicates the height value of the pen.
PageFlipPen
 Inheritedline : ILineStyle
Determinates the line style object of the pen.
Pen
  page1 : BitmapData
Determinates the first page bitmap to flip (left-top aligned).
PageFlipPen
  page2 : BitmapData
Determinates the second page bitmap to flip (left-top aligned).
PageFlipPen
  sensibility : int
Determinates the constraints sensibility.
PageFlipPen
  smoothing : Boolean = true
Indicates whether or not use pixel smoothing render.
PageFlipPen
 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
Determinates the width of this distort pen.
PageFlipPen
Public Methods
 MethodDefined By
  
PageFlipPen(graphic:*, page1:BitmapData, page2:BitmapData, ... rest)
Creates a new PageFlipPen instance.
PageFlipPen
 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
  
compute(drag:Point, corner:Point, w:int, h:int, isHorizontal:Boolean, sens:int):Object
[static] Computes and generates a new flip.
PageFlipPen
  
draw(... args):void
[override] Draws the shape and flip the two pages (BitmapData) into the provided Graphics.
PageFlipPen
  
drawShape():void
[override] This method contains the basic drawing shape algorithm.
PageFlipPen
 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(... args):void
Sets the shape options to defined all values to draw the shape.
PageFlipPen
  
setSize(width:Number, height:Number):void
Sets the size of this pen and re-initializes the triangular grid.
PageFlipPen
Protected Methods
 MethodDefined By
  
initialize():void
Initialize the pen.
PageFlipPen
Public Constants
 ConstantDefined By
  BOTTOM_LEFT : Point
[static] The bottom left position of the page.
PageFlipPen
  BOTTOM_RIGHT : Point
[static] The bottom right position of the page.
PageFlipPen
  TOP_LEFT : Point
[static] The top left position of the page.
PageFlipPen
  TOP_RIGHT : Point
[static] The top right position of the page.
PageFlipPen
Property Detail
cornerproperty
corner:Point

The original position of the dragged point.

You can use the PageFlipPen.BOTTOM_LEFT, PageFlipPen.BOTTOM_RIGHT, PageFlipPen.TOP_LEFT, PageFlipPen.TOP_RIGHT points.

The two possible values for its x and y properties are 0 or 1. pt(0,0) is the upper-left corner, for example, pt (1,1) is the bottom-right one.


Implementation
    public function get corner():Point
    public function set corner(value:Point):void
directionproperty 
direction:String

Indicates the direction value of this object. The values of this property are Direction.HORIZONTAL("horizontal") or Direction.VERTICAL("vertical").


Implementation
    public function get direction():String
    public function set direction(value:String):void

See also

dragproperty 
drag:Point

Indicates the position of the drag point relative to the upper-left corner.


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

Indicates the height value of the pen.


Implementation
    public function get height():Number
    public function set height(value:Number):void
page1property 
page1:BitmapData

Determinates the first page bitmap to flip (left-top aligned).


Implementation
    public function get page1():BitmapData
    public function set page1(value:BitmapData):void
page2property 
page2:BitmapData

Determinates the second page bitmap to flip (left-top aligned).


Implementation
    public function get page2():BitmapData
    public function set page2(value:BitmapData):void
sensibilityproperty 
sensibility:int

Determinates the constraints sensibility.

This parameter is a multiplicator for the constraints values.

It's intended to prevent some awefull flickering effects. Its possible value is ranged between 0.9 and 1. 0.9 -> when ptd move is free (drag'n'drop), 1 -> when the "drag" point move is progresive (tween when release). At best, you should never swap it from .9 to 1. A progressive incrementation is better. If flickering effects don't disturb you or if your ptd moves is coded, keep this parametter to 1.


Implementation
    public function get sensibility():int
    public function set sensibility(value:int):void
smoothingproperty 
public var smoothing:Boolean = true

Indicates whether or not use pixel smoothing render.

widthproperty 
width:Number

Determinates the width of this distort pen.


Implementation
    public function get width():Number
    public function set width(value:Number):void
Constructor Detail
PageFlipPen()Constructor
public function PageFlipPen(graphic:*, page1:BitmapData, page2:BitmapData, ... rest)

Creates a new PageFlipPen instance.

Parameters
graphic:* — The Graphics reference to control with this helper. You can passed-in a Shape or Sprite/MovieClip reference in argument.
 
page1:BitmapData — The first page bitmap (left-top aligned).
 
page2:BitmapData — The second page bitmap (left-top aligned).
 
... rest — All the optionals arguments to fill the setPen() method (see this method to defines all optional arguments)
Method Detail
compute()method
public static function compute(drag:Point, corner:Point, w:int, h:int, isHorizontal:Boolean, sens:int):Object

Computes and generates a new flip.

Parameters

drag:Point — The position of the drag point (the drag one) relative to the upper-left corner.
 
corner:Point — The original position of the dragged point.
 
w:int — indicating the sheet width in pixels.
 
h:int — indicating the sheet height in pixels.
 
isHorizontal:Boolean — If true, horizontal mode is provided, if false, vertical.
 
sens:int — The constraints sensibility.

Returns
Object — A generic object who containing the attributes :

  • cPoints:Array Array of points which describes the flipped part of the sheet. Note that in case of the ptd point is aligned with its original position or if the height of the shape is very small (>1) this array is set to null.
  • pPoints:Array Array of points wich describes the fixed part of the sheet.
  • matrix:Matrix Transformation matrix for the flipped part of the sheet.
  • width:Number Sheet width.
  • height:Number Sheet height.

draw()method 
override public function draw(... args):void

Draws the shape and flip the two pages (BitmapData) into the provided Graphics.

Parameters

... args — The position of the drag point relative to the upper-left corner.

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

This method contains the basic drawing shape algorithm.

initialize()method 
protected function initialize():void

Initialize the pen.

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

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

Parameters

... args — The position of the PTD point (the drag one) relative to the upper-left corner.

setSize()method 
public function setSize(width:Number, height:Number):void

Sets the size of this pen and re-initializes the triangular grid.

Parameters

width:Number — New width.
 
height:Number — New height.

Constant Detail
BOTTOM_LEFTConstant
public static const BOTTOM_LEFT:Point

The bottom left position of the page.

BOTTOM_RIGHTConstant 
public static const BOTTOM_RIGHT:Point

The bottom right position of the page.

TOP_LEFTConstant 
public static const TOP_LEFT:Point

The top left position of the page.

TOP_RIGHTConstant 
public static const TOP_RIGHT:Point

The top right position of the page.