Packagecom.rubenswieringa.book
Classpublic class Book
InheritanceBook Inheritance PageManager Inheritance mx.containers.Canvas

Book is a container class that creates a rich animated and interactive book from its contents, through which the end-user can browse by flipping the pages over (pageflip-effect). Its core functionality (for example storage of Page instances) is defined by the PageManager class, which the Book class extends.
Book itself describes the functionality for the management of pageflips. The actual pageflip class was written by Didier Brun (also mentioned in the credits).

Ruben Swieringa created this component during his internship at the Factor.e (www.tfe.nl). Thanks to those guys for allowing me to publish the source-code online!

See also

PageManager
Page
BookEvent
BookError
com.foxaweb.pageflip.PageFlip
org.flashsandy.display.DistortImage
Rubens blog: Book component beta


Public Properties
 PropertyDefined by
  autoFlipDuration : uint = 1000
The time (milliseconds) it takes to finish a pageflip performed by the gotoPage method.
Book
 InheritedcurrentPage : int
Index of the current left-hand page (-1 if the Book is unopened).
PageManager
  easing : Number
The precision with which the page-corner follows the mouse during a pageflip.
Book
  flipOnClick : Boolean = true
Whether or not the page should be turned when a page corner is clicked.
Book
  hardCover : Boolean
If true, the first and last Pages in this Book will be hard, regardless of the value of their own hard properties.
Book
  hardPerspective : uint = 45
Amount of perspective in a pageflip of a Page that has its hard property set to true.
Book
  hover : Boolean
Set this property to false if the four outer page-corners should not display a subtle flip-effect on mouse-over.
Book
  liveBitmapping : Boolean = false
Indicates whether or not this Book plays animation while flipping one of its Pages.
Book
 InheritedopenAt : int
Index of the Page at which the Book is opened at startup, can only be set once, and only at startup.
PageManager
 Inheritedpages : ArrayCollection
Array of all respective Pages in this Book instance.
PageManager
  regionSize : uint
Size of the hit-regions in the pagecorners.
Book
  sideFlip : Boolean = true
Whether or not the outer side of a Page can be used to let it flip.
Book
  snap : Boolean = false
If true, no easing will be applied during pageflips.
Book
  status : String
[write-only] Current status of the Book.
Book
  tearable : Boolean = false
If true, all Pages will have tearing enabled.
Book
Public Methods
 MethodDefined by
  
Book()
Constructor.
Book
 Inherited
addChild(child:DisplayObject):DisplayObject
Adds a child Page instance to this PageManager instance.
PageManager
 Inherited
addChildAt(child:DisplayObject, index:int):DisplayObject
Adds a child Page instance to this PageManager instance at the index position specified.
PageManager
  
cancelGotoPage(finishFlip:Boolean = true):void
Aborts a pageflip started by the gotoPage method.
Book
 Inherited
contains(child:DisplayObject):Boolean
Determines whether the specified display object is a child of the PageManager instance or the instance itself.
PageManager
 Inherited
getChildByName(name:String):DisplayObject
Returns the child display object that exists with the specified name.
PageManager
 Inherited
getChildIndex(child:DisplayObject):int
Returns the index position of a child Page instance.
PageManager
 Inherited
getChildren():Array
Returns an Array of Page objects consisting of the content children of the container.
PageManager
  
Returns a Point instance indicating the corner that was last flipped.
Book
 Inherited
getObjectsUnderPoint(point:Point):Array
Returns an array of objects that lie under the specified point and are children (or grandchildren, and so on) of this PageManager instance.
PageManager
  
gotoPage(page:*, cancelable:Boolean = true):void
Performs a pageflip without the user having to drag the pagecorner.
Book
  
nextPage():void
Performs a pageflip to the next page, without the user having to drag the pagecorner.
Book
 Inherited
owns(child:DisplayObject):Boolean
Returns true if the chain of owner properties points from child to this PageManager.
PageManager
  
prevPage():void
Performs a pageflip to the previous page, without the user having to drag the pagecorner.
Book
 Inherited
Removes all children (Page instances) from the child list of this container.
PageManager
 Inherited
removeChild(child:DisplayObject):DisplayObject
Removes a child Page from the child list of this Container.
PageManager
 Inherited
removeChildAt(index:int):DisplayObject
Removes a child Page from the child list of this Container at the specified index.
PageManager
 Inherited
setChildIndex(child:DisplayObject, newIndex:int):void
Changes the position of an existing child in the PageManager container.
PageManager
  
Swaps the position of two Page instances in the PageManager.
Book
 Inherited
swapChildrenAt(index1:int, index2:int):void
Swaps the position of two Page instances in the PageManager at the specified indexes.
PageManager
  
tearPage(page:*, fromTop:Boolean = true):void
Tears a Page out of this Book instance.
Book
Events
 EventSummaryDefined by
   Dispatched at the same time as the page-turned Event, when the Book was previously open, and the first or last Page was flipped successfully.Book
   Dispatched at the same time as the page-turned Event, when the Book was previously closed, and the first or last Page was flipped successfully.Book
 Inherited Dispatched when a page is added to or removed from the PageManager.PageManager
   Dispatched when the corner of a page is rolled out of with the mouse.Book
   Dispatched when a page falls back in place after being rolled over with the mouse.Book
   Dispatched when the corner of a page is rolled over with the mouse.Book
   Dispatched when the user releases the corner of a page.Book
   Dispatched when a page falls in place after being flipped.Book
   Dispatched when the user picks up the corner of a page.Book
   Dispatched when a pageflip is not successful.Book
   Dispatched when a Page is torn out of its Book.Book
   Dispatched when a pageflip is successful.Book
   Dispatched at the same time as the page-turned Event, when the Book was previously open, and the first or last Page was flipped successfully.Book
Property detail
autoFlipDurationproperty
public var autoFlipDuration:uint = 1000

The time (milliseconds) it takes to finish a pageflip performed by the gotoPage method. The calculated speed will also be used for tearing out Pages.

The default value is 1000.

See also

easingproperty 
easing:Number  [read-write]

The precision with which the page-corner follows the mouse during a pageflip. Values range from 0 (no easing) to 1 (heavy easing).

The default value is 0.7.

Implementation
    public function get easing():Number
    public function set easing(value:Number):void
flipOnClickproperty 
public var flipOnClick:Boolean = true

Whether or not the page should be turned when a page corner is clicked.

The default value is true.

hardCoverproperty 
hardCover:Boolean  [read-write]

If true, the first and last Pages in this Book will be hard, regardless of the value of their own hard properties.

The default value is true.

Implementation
    public function get hardCover():Boolean
    public function set hardCover(value:Boolean):void
hardPerspectiveproperty 
public var hardPerspective:uint = 45

Amount of perspective in a pageflip of a Page that has its hard property set to true. This value is used as the maximum with which the outer side of a page is extended on both sides (upper and lower) during a hard pageflip.

The default value is 45.

hoverproperty 
hover:Boolean  [read-write]

Set this property to false if the four outer page-corners should not display a subtle flip-effect on mouse-over. Note that Pages with their hard property set to true do not display hover-effects at all.

The default value is true.

Implementation
    public function get hover():Boolean
    public function set hover(value:Boolean):void
liveBitmappingproperty 
public var liveBitmapping:Boolean = false

Indicates whether or not this Book plays animation while flipping one of its Pages. When this property is set to true, all Page instances will return true from their liveBitmapping property. Note that enabling liveBitmapping may result in decreased performance.

The default value is false.

See also

regionSizeproperty 
regionSize:uint  [read-write]

Size of the hit-regions in the pagecorners.

The default value is 150.

Implementation
    public function get regionSize():uint
    public function set regionSize(value:uint):void
sideFlipproperty 
public var sideFlip:Boolean = true

Whether or not the outer side of a Page can be used to let it flip.

The default value is true.

snapproperty 
public var snap:Boolean = false

If true, no easing will be applied during pageflips.

The default value is false.

See also

statusproperty 
status:String  [write-only]

Current status of the Book.

This property can be used as the source for data binding.

Implementation
    public function set status(value:String):void

See also

tearableproperty 
public var tearable:Boolean = false

If true, all Pages will have tearing enabled.

The default value is false.

See also

Constructor detail
Book()constructor
public function Book()

Constructor.

Method detail
cancelGotoPage()method
public function cancelGotoPage(finishFlip:Boolean = true):void

Aborts a pageflip started by the gotoPage method.

Parameters
finishFlip:Boolean (default = true) — Boolean indicating whether or not to allow the auto-flip to finish. When true, the pageflip will finish. When false, the auto-flip will immediately stop, and the page corner will start sticking to the mouse.

See also

getLastFlippedCorner()method 
public function getLastFlippedCorner():Point

Returns a Point instance indicating the corner that was last flipped.

Returns
Point — Point
gotoPage()method 
public function gotoPage(page:*, cancelable:Boolean = true):void

Performs a pageflip without the user having to drag the pagecorner.

Parameters
page:* — int/uint or Page, indicating the index or instance of a Page.
 
cancelable:Boolean (default = true) — Indicates whether or not this auto-flip should allow cancelGotoPage to be called.

Throws
— Gets thrown when the child parameter is not an instance of the Page class nor a int/uint.
 
— Gets thrown when the child parameter is not a child of this Book.

See also

nextPage()method 
public function nextPage():void

Performs a pageflip to the next page, without the user having to drag the pagecorner.

See also

prevPage()method 
public function prevPage():void

Performs a pageflip to the previous page, without the user having to drag the pagecorner.

See also

swapChildren()method 
public override function swapChildren(child1:DisplayObject, child2:DisplayObject):void

Swaps the position of two Page instances in the PageManager.

Parameters
child1:DisplayObject — The first child object.
 
child2:DisplayObject — The second child object.
tearPage()method 
public function tearPage(page:*, fromTop:Boolean = true):void

Tears a Page out of this Book instance. When called, this method will be executed regardless of the value of the Page its tearable property. Fails silently if the provided Page is not one of the currently visible Pages.

Parameters
page:* — int/uint or Page, indicating the index or instance of a Page to be torn out of this Book.
 
fromTop:Boolean (default = true) — If true, the Page will be torn out by its upper outer corner, if false by its lower outer corner.

Throws
— Gets thrown when page is an index-value and out of bounds.

See also

Event detail
bookClosedevent 
Event object type: com.rubenswieringa.book.BookEvent

Dispatched at the same time as the page-turned Event, when the Book was previously open, and the first or last Page was flipped successfully.

See also

bookOpenedevent  
Event object type: com.rubenswieringa.book.BookEvent

Dispatched at the same time as the page-turned Event, when the Book was previously closed, and the first or last Page was flipped successfully.

See also

hoverEndingevent  
Event object type: com.rubenswieringa.book.BookEvent

Dispatched when the corner of a page is rolled out of with the mouse. Note that this Event is dispatched just before the page starts falling back in place. Only applicable if the hover property is set to true.

See also

hoverFinishedevent  
Event object type: com.rubenswieringa.book.BookEvent

Dispatched when a page falls back in place after being rolled over with the mouse. Only applicable if the hover property is set to true.

See also

hoverStartedevent  
Event object type: com.rubenswieringa.book.BookEvent

Dispatched when the corner of a page is rolled over with the mouse. Only applicable if the hover property is set to true.

See also

pageflipEndingevent  
Event object type: com.rubenswieringa.book.BookEvent

Dispatched when the user releases the corner of a page. Note that this Event is dispatched just before the page starts falling in place.

See also

pageflipFinishedevent  
Event object type: com.rubenswieringa.book.BookEvent

Dispatched when a page falls in place after being flipped. This Event is dispatched regardless of whether or not the page has been turned, or has fallen back into its original position.

See also

pageflipStartedevent  
Event object type: com.rubenswieringa.book.BookEvent

Dispatched when the user picks up the corner of a page.

See also

pageNotTurnedevent  
Event object type: com.rubenswieringa.book.BookEvent

Dispatched when a pageflip is not successful.

See also

pageTornevent  
Event object type: com.rubenswieringa.book.BookEvent

Dispatched when a Page is torn out of its Book.

pageTurnedevent  
Event object type: com.rubenswieringa.book.BookEvent

Dispatched when a pageflip is successful.

See also

statusChangedevent  
Event object type: com.rubenswieringa.book.BookEvent

Dispatched at the same time as the page-turned Event, when the Book was previously open, and the first or last Page was flipped successfully.

See also