• How do I use FlippingBook API for page in SWF?

The FlippingBook team has developed API for flipping pages, which can be used to improve your content. This article may be useful to you if you are familiar with ActionScript. Otherwise, you can pass the article on to the ActionScript developer or Flash designer in your company.

Note: This API works with the desktop version only.

How can API help me?

You can use API for the following scenarios:

  1. A page can get a page number and page range from the FlippingBook application.
  2. A page can monitor certain events from the FlippingBook application, such as open, close, start/end, zoom in/out.
  3. A page can use global data and share it with other pages.
  4. A page can save its current state and revert to it after reopening.


How can I use it?

You must use the fbapi.zip archive with certain classes and an example page.

First, add fb.swc to your project.

Second, get the page object reference . The main class of your page must implement the following interface:

package com.FlippingBook.Page
    public interface IPage
        function setBookPage(page:*):void;

For Example:

private var pageProxy: PageProxy;
public function setBookPage(bookPage:*):void
    pageProxy = new PageEnvironmentProxy(bookPage);


Page Environment

Use PageEnvironmentProxy class If you want to work with page environment.

public function get isZoomed():Boolean

Returns true if the book is in zoom mode. Always returns true for Photo Album and Document projects.


public function get pageNumber():int

Returns the page number.


public function get length():int

Returns the quantity of pages.


public function get isLeft():Boolean

Returns true for the left page.


public function get isRight():Boolean

Returns true for the right page.


public function get isWide():Boolean

Returns true for a wide page.

For Example:

public function setBookPage(bookPage:*):void
    bookProxy = new PageEnvironmentProxy(bookPage);
    pageNumber.text = bookProxy.pageNumber + "/" + bookProxy.length;


Page Events

Use PageEventProxy class if you want to work with page Events.

public static const PAGE_OPEN_EVENT
public static const PAGE_CLOSE_EVENT
public static const PAGE_ZOOM_IN_START_EVENT
public static const PAGE_ZOOM_OUT_START_EVENT
public static const PAGE_ZOOM_IN_END_EVENT
public static const PAGE_ZOOM_OUT_END_EVENT

For Example:

public function setBookPage(bookPage:*):void
    bookProxy = new PageEventProxy(bookPage);


Global Data

These methods allow some pages to use common data. For example, if you use FlippingBook for testing and each page contains a test set and the last page shows you the result.

Use GlobalDataProxy class if you want to work with global data.


public function setVar(varName:String, value:*): void

Sets a value for the global variable with the specified name.


public function getVar(varName:String):*

Returns a value for the global variable with the specified name.


public function hasVar(varName:String):Boolean

Indicates that the variable with the specified name is defined.


public function deleteVar(varName:String): void

Deletes the variable with the specified name from the Book Environment.


All of the following methods work like the previous one, but for a page. You can specify a pageNumber and work with data for the specified page. If you haven't specified a pageNumber, it means you will be working with data for the current page. For example, each page can calculate the result of the self-test set and the last page will summarize it.

Use PageDataProxy class if you want to work with page data.


public function setPageVar(varName:String, value:*,pageNumber:int = -1):void
public function getPageVar(varName:String, pageNumber:int = -1):*
public function hasPageVar(varName:String, pageNumber:int = -1):Boolean
public function deletePageVar(varName:String, pageNumber:int = -1):void



Use PageEnvironmentProxy class if you want to navigate to definite page.

public function navigateToPage(num:uint):void

A page can force FlippingBook to flip to any other page.

For Example:

private function setBookPage(bookPage:*):void
    bookProxy = new PageEnvironmentProxy(bookPage);

private function navigateToLastPage(e:Event):void

private function navigateToFirstPage(e:Event):void

private function navigateToNextPage(e:Event):void
    if ( bookProxy.pageNumber >= bookProxy.length)
    if (bookProxy.isLeft && !bookProxy.isZoomed)
        bookProxy.navigateToPage(bookProxy.pageNumber + 2);
        bookProxy.navigateToPage(bookProxy.pageNumber + 1);

private function navigateToPrevPage(e:Event):void
    if ( bookProxy.pageNumber <= 1)
        return ;
    if (bookProxy.isRight && !bookProxy.isZoomed)
        bookProxy.navigateToPage(bookProxy.pageNumber - 2);
        bookProxy.navigateToPage(bookProxy.pageNumber - 1);



If you want to debug your page in the Flipping Book application in Flash Builder:


  1. For your page project, change the URL or "path to launch" in "Debug Configurations" to something like this: "C:\some.bat".
  2. Create a Publication. Import your page and publish to HTML (C:\for_debug).
  3. Install Debug Flash Player on your browser.


  1. Copy your page into your project. Or create a bat file for automation and run it, for example:
    xcopy "pathtoyourpage.swf" C:\for_debug\files\assets\flash\pages\page0001.swf
  2. Run Debug.
  3. Close the Flash player.
  4. Run the publication C:\for_debug\index.html

Debugging in Flash Professional

  1. You cannot debug your page in Flash Professional, but you can get the debugging output and trace some debugging information. For that you must:
  2. Import your page.
  3. Publish to HTML.
    (Instead of the previous points, you can copy your page into the prepared publication, as was described for Flash Builder)
  4. Run the publication.
  5. Begin the remote debug session.


Was this article helpful?