FlashPaper API接口开发

来源:互联网 发布:尼康相机设定优化校准 编辑:程序博客网 时间:2024/05/16 11:40

FlashPaperComponent Documentation


FlashPaper(com.digitalflipbook.controls.FlashPaper)

Component

        |

       +--com.digitalflipbook.controls.FlashPaper

classFlashPaper
extends Component

TheFlashPaper class simplifies the process of working with the FlashPaper API.
Adds functionality either not documented or not provided in the API.

Availability:

ActionScript1.0; Flash Player 6

Methodsummary

Method

Description

load(path:String) : Void

Loads a FlashPaper document.

destroy() : Void

Unloads a FlashPaper document and all subobjects.

move(x:Number, y:Number) : Void

Moves the FlashPaper component to the requested position.

toString() : String

This returns the component's class name.

getIFlashPaper() : FlashPaper.IFlashPaper

This returns an object that implements the IFlashPaper interface.
If this function is not defined, then the SWF file is not a FlashPaper 2.0 document.
If this function exists, but returns a value of null or undefined, then the SWF file is a FlashPaper 2.0 document, but has not yet loaded enough to access the API; you must wait for it to load more fully and call it again.

getViewerType() : String

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.

getViewerVersion() : Number

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.

getCurrentPage() : Number

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

setCurrentPage(pageNumber:Number) : Void

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

getNumberOfPages() : Number

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.

getLoadedPages() : Number

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.

showUIElement(part:String, flag:Boolean) : Void

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.

traceUIElements() : Void

Traces the visiblity of the UI Elements.

printTheDocument() : Boolean

Simulates a user clicking the Print button.
The document must be fully loaded before you call this function.

getCurrentZoom() : Number

Returns the current zoom level.
Note: The zoom level always returns as a number; width and page are never returned.

setCurrentZoom(percent:Object) : Void

Sets the current zoom level.
You can pass a number indicating a zoom percentage
(for example, 100 for a 100% view).
You can also pass 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.

setSize(w:Number, h:Number) : Boolean

Sets the display arrange of the component, in pixels.
This function returns true if resize was successful, false if resize was unsuccessful.

goToLinkTarget(linktarget:String, window:Object) : Void

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.)

enableScrolling(flag:Boolean) : Boolean

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.

getCurrentTool() : String

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)

setCurrentTool(tool:String) : Boolean

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)

getTextSelectionRange() : FlashPaper.SelectionRange

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.

setTextSelectionRange(sel:FlashPaper.SelectionRange, skipBroadcast:Boolean) : Void

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.

getSelectedText() : String

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

getSidebarWidth() : Number

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

setSidebarWidth(w:Number) : Void

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

getFindText() : String

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

setFindText(s:String) : Void

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.

findNext() : Boolean

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.
If text is found, the specific range can be found by calling getTextSelectionRange().

getVisibleArea() : Object

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.

setVisibleArea(area:Object, skipBroadcast:Boolean) : Void

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.

documentPath() : String

The path of the FlashPaper document.

borderThickness() : Number

The thickness of the border.

borderColor() : String

The color of the border.

UIElements() : Object

The visiblity of the UI Elements.

currentZoom() : Object

The current zoom level.

backgroundTintColor() : String

The tint color of the background.

backgroundTintPercent() : Number

The tint percent of the background.

width() : Number

The width of the FlashPaper component.

height() : Number

The height of the FlashPaper component.

load(path:String) : Void

Usage

myFlashPaper.load(path);

Parameters

path:String - Thelocal or remote address of the document to load.

Returns

Nothing.

Description

Loadsa FlashPaper document.


destroy() : Void

Usage

myFlashPaper.destroy();

Parameters

Returns

Nothing.

Description

Unloadsa FlashPaper document and all subobjects.


move(x:Number, y:Number) : Void

Usage

myFlashPaper.move(x, y);

Parameters

x:Number - Anumber that indicates the upper left corner position of the FlashPapercomponent.

y:Number - Anumber that indicates the upper left corner position of the FlashPapercomponent.

Returns

Nothing.

Description

Movesthe FlashPaper component to the requested position.


toString() : String

Usage

myFlashPaper.toString();

Parameters

Returns

"FlashPaper"

Description

Thisreturns the component's class name.


getIFlashPaper() : FlashPaper.IFlashPaper

Usage

myFlashPaper.getIFlashPaper();

Parameters

Returns

TheFlashPaper interface.

Description

Thisreturns an object that implements the IFlashPaper interface.
If this function is not defined, then the SWF file is not a FlashPaper 2.0document.
If this function exists, but returns a value of null or undefined, then the SWFfile is a FlashPaper 2.0 document, but has not yet loaded enough to access theAPI; you must wait for it to load more fully and call it again.


getViewerType() : String

Usage

myFlashPaper.getViewerType();

Parameters

Returns

Theviewer type.

Description

Returnsa string describing the type of user interface that is included in thedocument.
The standard Macromedia FlashPaper viewer always returns the string MacromediaFlashPaper Default Viewer.


getViewerVersion() : Number

Usage

myFlashPaper.getViewerVersion();

Parameters

Returns

Theviewer version.

Description

Returnsan integer indicating the version of the user interface code in this particulardocument.
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.


getCurrentPage() : Number

Usage

myFlashPaper.getCurrentPage();

Parameters

Returns

Thecurrent page.

Description

Returnsthe current page number (as displayed in the toolbar).
The first page is page 1.


setCurrentPage(pageNumber:Number) : Void

Usage

myFlashPaper.setCurrentPage(pageNumber);

Parameters

pageNumber:Number -Page number to set.

Returns

Nothing.

Description

Setsthe current page.
The view scrolls as necessary to ensure the page is visible, but does not adjustzoom.


getNumberOfPages() : Number

Usage

myFlashPaper.getNumberOfPages();

Parameters

Returns

Thetotal number of pages in the document.

Description

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


getLoadedPages() : Number

Usage

myFlashPaper.getLoadedPages();

Parameters

Returns

Thenumber of pages currently loaded.

Description

Returnsthe total number of pages loaded (and able to be displayed) so far.
This value must be between zero and getNumberOfPages(), inclusive.
When

getLoadedPages() == getNumberOfPages()

, thedocument is fully loaded.


showUIElement(part:String, flag:Boolean) : Void

Usage

myFlashPaper.showUIElement(part, flag);

Parameters

part:String - TheUI element to show or hide.

flag:Boolean - Iftrue, shows the UI element. If false, hides the UI element.

Returns

Nothing.

Description

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

"PrevNext" ThePrevious Page and Next Page toolbar buttons are hidden or shown.
Note: If these buttons are hidden, the Current Page text box isdisabled, but not hidden.

"Print" ThePrint toolbar button is hidden or shown.

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

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

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

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

"Sidebar" Thesidebar (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" TheCurrent Page and Number of Pages fields in the toolbar are hidden or shown.

"Overflow" TheOverflow menu on the toolbar is hidden or shown.
Note: This menu appears only when the toolbar is too narrow to displayall controls; you cannot use this call to force the Overflow menu to bevisible.

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

"Brand" TheBrand toolbar button is hidden or shown.

"Close" TheClose toolbar button is hidden or shown.


traceUIElements() : Void

Usage

myFlashPaper.traceUIElements();

Parameters

Returns

Nothing.

Description

Tracesthe visiblity of the UI Elements.


printTheDocument() : Boolean

Usage

myFlashPaper.printTheDocument();

Parameters

Returns

Returnsfalse if the document is not fully loaded.

Description

Simulatesa user clicking the Print button.
The document must be fully loaded before you call this function.


getCurrentZoom() : Number

Usage

myFlashPaper.getCurrentZoom();

Parameters

Returns

Thecurrent zoom level of the document.

Description

Returnsthe current zoom level.
Note: The zoom level always returns as a number; width and page are neverreturned.


setCurrentZoom(percent:Object) : Void

Usage

myFlashPaper.setCurrentZoom(percent);

Parameters

percent:Object - Thezoom level to set the FlashPaper document.

Returns

Nothing.

Description

Setsthe current zoom level.
You can pass a number indicating a zoom percentage
(for example, 100 for a 100% view).
You can also pass the string "width" to zoom to the currentfit-to-width magnification for this document, or pass the string"page" for the fit-to-page magnification.


setSize(w:Number, h:Number) : Boolean

Usage

myFlashPaper.setSize(w, h);

Parameters

w:Number -Width to set the FlashPaper document.

h:Number -Height to set the FlashPaper document.

Returns

Generallyspeaking, this function fails (returns false) if the document isn't fullyloaded.

Description

Setsthe display arrange of the component, in pixels.
This function returns true if resize was successful, false if resize wasunsuccessful.


goToLinkTarget(linktarget:String, window:Object) :Void

Usage

myFlashPaper.goToLinkTarget(linktarget, window);

Parameters

linktarget:String -Anchor or URL link to load.

window:Object - Anoptional parameter specifying the window or HTML frame into which the documentshould load.

Returns

Nothing.

Description

Handlesan anchor or URL link request.
If the given string is a string of the form anchor:foo, the current view shiftsto 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.)


enableScrolling(flag:Boolean) : Boolean

Usage

myFlashPaper.enableScrolling(flag);

Parameters

flag:Boolean -True or false to enable scrolling.

Returns

Thereturn value is the previous value of this flag.

Description

Usedto prevent the user from scrolling the document.
When scrolling is disabled, the following is true:

Thescroll bar is disabled, but visible.
Panning (using the pointing hand) is disabled.
Scrolling using the mouse wheel is disabled.


getCurrentTool() : String

Usage

myFlashPaper.getCurrentTool();

Parameters

Returns

Thecurrent tool.

Description

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

"" (no tool)
"pan" (handtool)
"select" (textselection tool)


setCurrentTool(tool:String) : Boolean

Usage

myFlashPaper.setCurrentTool(tool);

Parameters

tool:String -Tool to make active.

Returns

If thetool was set successfully.

Description

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

"" (notool)
"pan" (handtool)
"select" (textselection tool)


getTextSelectionRange() : FlashPaper.SelectionRange

Usage

myFlashPaper.getTextSelectionRange();

Parameters

Returns

Thecurrent text selection range.

Description

Returnsan object describing the current text selection. If no text is selected, thisfunction returns null.
Note: Unlike the object returned by getVisibleArea(), this call alwaysreturns a FlashPaper.SelectionRange, which is a well-defined object that youcan examine, decompose, or construct new instances of.


setTextSelectionRange(sel:FlashPaper.SelectionRange,skipBroadcast:Boolean) : Void

Usage

myFlashPaper.setTextSelectionRange(sel, skipBroadcast);

Parameters

sel:FlashPaper.SelectionRange -FlashPaper.SelectionRange.

skipBroadcast:Boolean - Iffalse or omitted, onVisibleAreaChanged() is broadcast. If true, the event isnot broadcast.

Returns

Nothing.

Description

Selectsthe given range of text. You may pass null to deselect all text. Invalid rangesfor characters (not pages) are clipped to document ranges (this allows you toset 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 skipBroadcastis true, onVisibleAreaChanged() is never broadcast to listeners.
Note: Unlike the object expected by setVisibleArea(), this call alwaysexpects a FlashPaper.SelectionRange, which is a well-defined object that youcan examine, decompose, or construct new instances of.


getSelectedText() : String

Usage

myFlashPaper.getSelectedText();

Parameters

Returns

Thetext currently selected.

Description

Returnsthe selected text as a Unicode string.
If no text is selected, an empty string is returned.


getSidebarWidth() : Number

Usage

myFlashPaper.getSidebarWidth();

Parameters

Returns

Thewidth of the sidebar.

Description

Returnsthe width of the sidebar.
A document with no outline always returns zero.


setSidebarWidth(w:Number) : Void

Usage

myFlashPaper.setSidebarWidth(w);

Parameters

w:Number -Width to set sidebar.

Returns

Nothing.

Description

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


getFindText() : String

Usage

myFlashPaper.getFindText();

Parameters

Returns

Thetext in the Find text box as a Unicode string.

Description

Returnsany text in the Find text box as a Unicode string.


setFindText(s:String) : Void

Usage

myFlashPaper.setFindText(s);

Parameters

s:String -Text to set in the Find text box.

Returns

Nothing.

Description

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


findNext() : Boolean

Usage

myFlashPaper.findNext();

Parameters

Returns

Returnstrue if text is found, false if not.

Description

Searchesfor 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.
If text is found, the specific range can be found by callinggetTextSelectionRange().


getVisibleArea() : Object

Usage

myFlashPaper.getVisibleArea();

Parameters

Returns

Thecurrent visible area of the document.

Description

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

Passto 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 theviewable area has changed.

The returnedobject should be considered an opaque data type.
Don't try to decompose the returned object, because its contents and formatwill probably change in future versions.
The only public member of the object we guarantee in future versions of themethod is:

function equals(that:Object):Boolean;


You can use this to compare two visible areas to determine if they are thesame.


setVisibleArea(area:Object, skipBroadcast:Boolean) :Void

Usage

myFlashPaper.setVisibleArea(area, skipBroadcast);

Parameters

area:Object -Object to match current visible area with.

skipBroadcast:Boolean - Iffalse or omitted, onVisibleAreaChanged() is broadcast. If true, the event isnot broadcast.

Returns

Nothing.

Description

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


documentPath() : String

Usage

myFlashPaper.documentPath = path;

Parameters

Returns

Nothing.

Description

Thepath of the FlashPaper document.


borderThickness() : Number

Usage

myFlashPaper.borderThickness = thickness;

Parameters

Returns

Nothing.

Description

Thethickness of the border.


borderColor() : String

Usage

myFlashPaper.borderColor = color;

Parameters

Returns

Nothing.

Description

Thecolor of the border.


UIElements() : Object

Usage

myFlashPaper.UIElements = elements;

Parameters

Returns

Nothing.

Description

Thevisiblity of the UI Elements.


currentZoom() : Object

Usage

myFlashPaper.currentZoom = percent;

Parameters

Returns

Nothing.

Description

Thecurrent zoom level.


backgroundTintColor() : String

Usage

myFlashPaper.backgroundTintColor = color;

Parameters

Returns

Nothing.

Description

Thetint color of the background.


backgroundTintPercent() : Number

Usage

myFlashPaper.backgroundTintPercent = percent;

Parameters

Returns

Nothing.

Description

Thetint percent of the background.


width() : Number

Usage

myFlashPaper.width = w;

Parameters

Returns

Nothing.

Description

Thewidth of the FlashPaper component.


height() : Number

Usage

myFlashPaper.height = h;

Parameters

Returns

Nothing.

Description

Theheight of the FlashPaper component.


 

相关调用方法如下:

function loadFlashPaper( 
path_s, // path of SWF to load 
dest_mc, // MC which we should replace with the SWF 
width_i, // new size of the dest MC 
height_i, // new size of the dest MC 
loaded_o) // optional: object to be notified that loading is complete 

var intervalID = 0; 
var loadFunc = function() 

dest_mc._visible = false; 
var fp = dest_mc.getIFlashPaper(); 
if (!fp) 
return; 
if (fp.setSize(width_i, height_i) == false) 
return; 
dest_mc._visible = true; 
clearInterval(intervalID); 
loaded_o.onLoaded(fp); 

intervalID = setInterval(loadFunc, 100); 
dest_mc.loadMovie(path_s); 

function onLoaded(fp) 

// loading is complete, so we can now adjust the current page, zoom, etc. 
// go to page 50. 
fp.setCurrentPage(1); 
// change magnification to 100% 
fp.setCurrentZoom(100); 

loadFlashPaper("1.swf", paper, Stage.width, Stage.height, this); 

原创粉丝点击