FlashPaper Documentation

UPDATE: FlashPaper 0.7 has been released.

Follow this link for the latest documentation.

Author: Mark Walters
Last Modified: 01/19/05 16:26:29


Summary

FlashPaper class:

- description

FlashPaper Properties:

- documentPath
- borderThickness
- borderColor
- currentZoom

FlashPaper Methods:

- getViewerType
- getViewerVersion
- getCurrentPage
- setCurrentPage
- getNumberOfPages
- getLoadedPages
- showUIElement
- traceUIElements
- printTheDocument
- setSize
- goToLinkTarget
- enableScrolling
- getCurrentTool
- setCurrentTool
- getTextSelectionRange
- setTextSelectionRange
- getTextSelected
- getSidebarWidth
- setSidebarWidth
- getFindText
- setFindText
- findNext
- getVisibleArea
- setVisibleArea
- load
- destroy
- addListener
- removeListener


FlashPaper class

version: 0.6

description:

FlashPaper component.
Simplifies the process of working with the FlashPaper API.
Adds functionality either not documented or not provided in the API.

events:

 onFlashPaperLoaded
 onFlashPaperDisplayed
 onFlashPaperUnloaded
 onPageChanged
 onZoomChanged
 onSelection
 onToolChanged
 onEnableScrolling
 onVisibleAreaChanged
 

usage:

Drag the FlashPaper component onto the stage and enter in values for the following properties:

 Border Color
 Border Thickness
 Current Zoom
 Document Path
 UI Elements
 
Give the component on stage an instance name and call a method or get / set a property.

myFlashPaper.method()
trace(myFlashPaper.property)
myFlashPaper.property = value

FlashPaper Properties:

documentPath

(String) The path to the FlashPaper document.

borderThickness

(Number) The thickness of the border.

borderColor

(String) The color of the border.

currentZoom

(Object) The current zoom level.
It can be set to a number indicating a zoom percentage (for example, 100 for a 100% view).
It can also be set to the string "width" to zoom to the current fit-to-width magnification for this document,
or pass the string "page" for the fit-to-page magnification.


FlashPaper Methods:

getViewerType

description: Returns a string describing the type of user interface that is included in the document.
The standard Macromedia FlashPaper viewer always returns the string Macromedia FlashPaper Default Viewer.

usage: myFlashPaper.getViewerType()

returns: String

getViewerVersion

description: Returns an integer indicating the version of the user interface code in this particular document.
The returned integers are arbitrary and not necessarily consecutive,
but larger numbers indicate recent revisions to the viewer,
and might indicate bug fixes or enhanced functionality.
FlashPaper 2.01 shipped with a viewer version number of 218.

usage: myFlashPaper.getViewerVersion()

returns: Number

getCurrentPage

description: Returns the current page number (as displayed in the toolbar).
The first page is page 1.

usage: myFlashPaper.getCurrentPage()

returns: Number

setCurrentPage

description: Sets the current page.
The view scrolls as necessary to ensure the page is visible, but does not adjust zoom.

usage: myFlashPaper.setCurrentPage(pageNumber)

parameters:

returns: Void

getNumberOfPages

description: Returns the total number of pages in the document.
Note: All of the pages may not be able to be displayed yet, depending on the connection speed.

usage: myFlashPaper.getNumberOfPages()

returns: Number

getLoadedPages

description: Returns the total number of pages loaded (and able to be displayed) so far.
This value must be between zero and getNumberOfPages(), inclusive.
When getLoadedPages() == getNumberOfPages(), the document is fully loaded.

usage: myFlashPaper.getLoadedPages()

returns: Number

showUIElement

description: Hides or displays part of the user interface in the FlashPaper document.
The currently supported, case-sensitive values for part are the following:

"PrevNext" The Previous Page and Next Page toolbar buttons are hidden or shown.
Note: If these buttons are hidden, the Current Page text box is disabled, but not hidden.

"Print" The Print toolbar button is hidden or shown.

"Tool" All tool selection buttons on the toolbar are hidden or shown.

"Zoom" All zoom-related controls on the toolbar are hidden or shown.

"Find" All text-search-related controls on the toolbar are hidden or shown.

"Pop" The Open Document in New Browser Window toolbar button is hidden or shown.

"Sidebar" The sidebar (displaying the document outline) is hidden or shown.
Note: This value is ignored if the document does not contain an outline; documents without outlines never show a sidebar.

"Page" The Current Page and Number of Pages fields in the toolbar are hidden or shown.

"Overflow" The Overflow menu on the toolbar is hidden or shown.
Note: This menu appears only when the toolbar is too narrow to display all controls; you cannot use this call to force the Overflow menu to be visible.

"ZoomKeys" This value doesn't affect the user interface; it is used to enable or disable various keys used to zoom in or out of the document (for example, +, -, p, w).

"Brand" The Brand toolbar button is hidden or shown.

"Close" The Close toolbar button is hidden or shown.

usage: myFlashPaper.showUIElement(part, flag)

parameters:

returns: Void

traceUIElements

description: Traces the visiblity of the UI Elements.

usage: myFlashPaper.traceUIElements()

returns: Void

printTheDocument

description: Simulates a user clicking the Print button.
The document must be fully loaded before you call this function.
This function returns false if the document is not fully loaded.

usage: myFlashPaper.printTheDocument()

returns: Boolean

setSize

description: Sets the display size of the component, in pixels.
This function returns true if resize was successful, false if resize was unsuccessful.
Generally speaking, this function fails (returns false) if the document isn't fully loaded.

usage: myFlashPaper.setSize(w, h)

parameters:

returns: Boolean

goToLinkTarget

description: Handles an anchor or URL link request.
If the given string is a string of the form anchor:foo, the current view shifts to that anchor with a logical name of foo.
The window argument is ignored in this case.
If foo is not a valid anchor name in the document, no action is taken.
For all other strings, getURL(linktarget, window) is called.
(For more information, see the ActionScript documentation for this function.)

usage: myFlashPaper.goToLinkTarget(linktarget, window)

parameters:

returns: Void

enableScrolling

description: Used to prevent the user from scrolling the document.
When scrolling is disabled, the following is true:

The scroll bar is disabled, but visible.
Panning (using the pointing hand) is disabled.
Scrolling using the mouse wheel is disabled.
The return value is the previous value of this flag.

usage: myFlashPaper.enableScrolling(flag)

parameters:

returns: Boolean

getCurrentTool

description: Returns the currently active tool.
If no tool is active, an empty string is returned.
The following are currently supported values:

"" (no tool)
"pan" (hand tool)
"select" (text selection tool)

usage: myFlashPaper.getCurrentTool()

returns: String

setCurrentTool

description: Makes the given tool the active tool.
This function returns false if the argument is invalid or the given tool is disabled.
The following are currently supported values:

"" (no tool)
"pan" (hand tool)
"select" (text selection tool)

usage: myFlashPaper.setCurrentTool(tool)

parameters:

returns: Boolean

getTextSelectionRange

description: Returns an object describing the current text selection. If no text is selected, this function returns null.
Note: Unlike the object returned by getVisibleArea(), this call always returns a FlashPaper.SelectionRange, which is a well-defined object that you can examine, decompose, or construct new instances of.

usage: myFlashPaper.getTextSelectionRange()

returns: Object

setTextSelectionRange

description: Selects the given range of text. You may pass null to deselect all text. Invalid ranges for characters (not pages) are clipped to document ranges (this allows you to set a range that begins with zero and ends with a large number, such as 999999, to select the entire document). If skipBroadcast is false (or omitted), onVisibleAreaChanged() is broadcast to listeners as necessary. If skipBroadcast is true, onVisibleAreaChanged() is never broadcast to listeners.
Note: Unlike the object expected by setVisibleArea(), this call always expects a FlashPaper.SelectionRange, which is a well-defined object that you can examine, decompose, or construct new instances of.

usage: myFlashPaper.setTextSelectionRange(headPageIdx, tailPageIdx, headCharIdx, tailCharIdx, skipBroadcast)

parameters:

returns: Void

getTextSelected

description: Returns the selected text as a Unicode string.
If no text is selected, an empty string is returned.

usage: myFlashPaper.getTextSelected()

returns: String

getSidebarWidth

description: Returns the width of the sidebar.
A document with no outline always returns zero.

usage: myFlashPaper.getSidebarWidth()

returns: Number

setSidebarWidth

description: Sets the width of the sidebar.
Pass zero to hide the sidebar completely.
A document with no outline ignores this call.

usage: myFlashPaper.setSidebarWidth(w)

parameters:

returns: Void

getFindText

description: Returns any text in the Find text box as a Unicode string.

usage: myFlashPaper.getFindText()

returns: String

setFindText

description: Sets the text in the Find text box to a Unicode string value.
This call does not perform a find operation or alter the current selection.

usage: myFlashPaper.setFindText(s)

parameters:

returns: Void

findNext

description: Searches for the text in the Find text box.
The search begins from the end of the current selection.
To start from the beginning of the document, call setSelectionRange(null) first.
Returns true if text is found, false if not.
If text is found, the specific range can be found by calling getTextSelectionRange().

usage: myFlashPaper.findNext()

returns: Boolean

getVisibleArea

description: Returns an object describing the current visible area of the document.
You can use the return value to do one of the following:

Pass to setVisibleArea().
This can be useful if the same document is being viewed on multiple computers, and you want to keep the visible areas in sync.

Compare with a previous value returned by getVisibleArea() to determine if the viewable area has changed.
The returned object should be considered an opaque data type.
Don't try to decompose the returned object, because its contents and format will probably change in future versions.
The only public member of the object we guarantee in future versions of the method is:
function equals(that:Object):Boolean;
You can use this to compare two visible areas to determine if they are the same.

usage: myFlashPaper.getVisibleArea()

returns: Object

setVisibleArea

description: Adjusts the currently visible page/zoom/scroll to match the visible area described by the area object.
If skipBroadcast is false (or omitted), onVisibleAreaChanged() is broadcast to listeners as necessary.
If skipBroadcast is true, onVisibleAreaChanged() is never broadcast to listeners.
This object must be one previously returned by getVisibleArea.
Don't try to construct your own object, because the contents and format will probably change in future versions.

usage: myFlashPaper.setVisibleArea(area, skipBroadcast)

parameters:

returns: Void

load

description: Loads a FlashPaper document.
Broadcasts onFlashPaperLoaded once the document has loaded.
Broadcasts onFlashPaperDisplayed once the document has displayed.

usage: myFlashPaper.load(path)

parameters:

returns: Void

destroy

description: Unloads a FlashPaper document and all subobjects.
Broadcasts onFlashPaperUnloaded

usage: myFlashPaper.destroy()

returns: Void

addListener

description: Adds a listener for the following events:

onPageChanged(newPageNumber:Number):Void Broadcast when the current page (as displayed in the toolbar) changes.
onZoomChanged(percent:Number):Void Broadcast when the current zoom level (as displayed in the toolbar) changes.
onSelection():Void Broadcast when the current text selection in the document changes. (For efficiency, the new selection is not passed as an argument; you should call getTextSelectionRange() to get the new selection.)
onToolChanged(newTool:String):Void Broadcast when the currently active tool (as displayed in the toolbar) changes.
onEnableScrolling(enable:Boolean):Void Broadcast when scrolling is enabled or disabled, typically by a call to enableScrolling().
onVisibleAreaChanged():Void Broadcast when any aspect of the visible area of the document changes, including zoom level and scroll position.
Note: onFlashPaperLoaded(), onFlashPaperDisplayed(), and onFlashPaperUnloaded() need to be handled through Flash's component event handling and listener objects.

usage: myFlashPaper.addListener(listener)

parameters:

returns: Void

removeListener

description: Removes a listener added by addListener().
If the given object is not a listener for this FlashPaper document, the call does nothing.
Note: onFlashPaperLoaded(), onFlashPaperDisplayed(), and onFlashPaperUnloaded() need to be handled through Flash's component event handling and listener objects.

usage: myFlashPaper.removeListener(listener)

parameters:

returns: Void




generated with AS2docGenerator beta 0.5.3