Académique Documents
Professionnel Documents
Culture Documents
This version of FlashPaper does not work well when embedded in other Flash
documents.
Note: The FlashPaper 1.0 viewer did not implement function getNumberOfPages()
correctly and may return undefined as the value.
FlashPaper 1.01 supports the functions supported by FlashPaper 1.0 and adds
support for several other useful functions.
function getViewerType() Returns a string that describes the type of the viewer.
The standard Macromedia-provided viewer always returns Macromedia FlashPaper
Default Viewer.
function printTheDocument() Opens the Print dialog box. This call behaves as if
the user had clicked the Print button. Returns true if successful, false if not.
Note: The SWF file must be completely loaded for function printTheDocument() to
succeed; if it returns false, that is generally because the document has not yet fully
loaded.
function getCurrentZoom() Returns the current zoom level. Only numeric values
are returned (never width or page). If the viewer doesn't support varying zoom
levels, this function returns zero.
function onZoomChanged(percent) Called by the document when the zoom
level changes. Default function does nothing. Can be overwritten by a container
that wants to trap this event.
function setSize( w, h ) Sets the display size of the SWF file, in pixels. Returns
true if resize was successful, false if not. This call should not be used unless the
SWF file is embedded inside another SWF file.
Note: This call returns false until at least the first page of the document loads, so
you may need to call it repeatedly until it returns true.
function 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. For more information, see Loading FlashPaper 2.0
documents into Flash.
interface FlashPaper.IFlashPaper
{
function addListener(listener:Object):Void;
function removeListener(listener:Object):Void;
function getViewerType():String;
function getViewerVersion():Number;
function getCurrentPage():Number;
function setCurrentPage(pageNumber:Number):Void;
function getNumberOfPages():Number;
function getLoadedPages():Number;
function showUIElement(part:String, flag:Boolean):Void;
function printTheDocument():Boolean;
function setCurrentZoom(percent:Object):Void;
function getCurrentZoom():Number;
function setSize(w:Number, h:Number):Boolean;
function goToLinkTarget(linktarget:String, window:Object):Void;
function enableScrolling(flag:Boolean):Boolean
function getCurrentTool():String;
function setCurrentTool(tool:String):Boolean;
function getTextSelectionRange():FlashPaper.SelectionRange;
function setTextSelectionRange(sel:FlashPaper.SelectionRange,
skipBroadcast:Boolean):Void;
function getSelectedText():String;
function getSidebarWidth():Number;
function setSidebarWidth(w:Number):Void;
function getFindText():String;
function setFindText(s:String):Void;
function findNext():Boolean;
function getVisibleArea():Object;
function setVisibleArea(area:Object, skipBroadcast:Boolean):Void;
};
Other events might be broadcast, but those events might not be in future versions
of FlashPaper. You should not rely on undocumented events broadcast by this
mechanism.
Note: All of the pages may not be able to be displayed yet, depending on the
connection speed.
"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.
"Tool" All tool selection buttons on the toolbar are hidden or shown.
"Pop" The Open Document in New Browser Window toolbar button 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.
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).
Note: The zoom level always returns as a number; width and page are never
returned.
For all other strings, getURL(linktarget, window) is called. (For more information, see
the ActionScript documentation for this function.)
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:SelectionRange, skipBroadcast:Boolean):Void;
Selects the given range of text. You may pass null to deselect all text. Invalid ranges
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).
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.
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. Returns true if text is found, false if not. If text is
found, the specific range can be found by calling getTextSelectionRange().
• Pass to setVisibleArea().
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.
class FlashPaper.SelectionRange
{
public var headPageIdx:Number;
public var headCharIdx:Number;
public var tailPageIdx:Number;
public var tailCharIdx:Number;
function equals(that:FlashPaper.SelectionRange):Boolean
{
return this.headPageIdx == that.headPageIdx &&
this.headCharIdx == that.headCharIdx &&
this.tailPageIdx == that.tailPageIdx &&
this.tailCharIdx == that.tailCharIdx;
}
};
It's important to understand is that a FlashPaper document is a SWF file; you can
load it as you would any other SWF file using loadMovie(), loadMovieNum(),
MovieClipLoader, and so on.
One important thing to watch for is the size of MovieClip after loading. As with all
SWF files loaded in Flash using loadMovie() and related calls, the MovieClip resizes
itself to the native size of the loaded SWF file, which is always 550 x 400 for
FlashPaper 2.0 documents.
To set a different size (to fit into an existing layout), you would typically use code
similar to this:
dest_mc.loadMovie("foo.swf");
//
// wait for loading to complete
//
dest_mc._width = 300; // resize to 300x200
dest_mc._height = 200;
While this code works for Flash documents, it won't give you the desired result; it
produces a strangely squashed result. This happens because adjusting the _width
and _height fields on a MovieClip doesn't actually adjust the size—it adjusts the
scaling factor.
So, you need to tell the FlashPaper document to resize itself. You can easily do this,
using the setSize() call as follows:
dest_mc.loadMovie("foo.swf");
//
// wait for loading to complete
//
dest_mc.getIFlashPaper().setSize(300, 200); // resize to 300x200
This code almost works. The problem is the wait for loading to complete comment—
it requires waiting a variable number of frames, depending on various factors,
including the number of frames in the SWF file being loaded and connection speed.
One way to deal with this is to use the MovieClipLoader class provided in Flash
Player 7. However, FlashPaper 2.0 documents require Flash Player 6 or later, so
using this class might unnecessarily limit your deployment. So, there's an alternate
function that is safe for use with Flash Player 6 or later:
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);
}
You can use this function to load a FlashPaper document into a MovieClip and resize
it appropriately when loading is complete.
Note: This function assumes that the SWF file being loaded is a FlashPaper
document. This function will execute forever for other SWF files, so use it with
caution.
Suppose you have an existing MovieClip named "fp_mc" that you want to replace
with a FlashPaper document, and you want the loaded document to be resized to be
the same size as the existing MovieClip. You could use the following code:
loadFlashPaper("MyFlashPaperDocument.swf",
fp_mc,
fp_mc._width,
fp_mc._height,
null);
If you want to do additional work when the document is fully loaded, you could also
use an optional listener object. This example scrolls to the last page of the
document and changes the document magnification to 33%:
loadFlashPaper("MyFlashPaperDocument.swf",
fp_mc,
fp_mc._width,
fp_mc._height,
loadNotifier);
If you want to alter the FlashPaper document toolbar, or add a listener for various
events, onLoaded is an excellent place to do so. Here's an example that hides the
Print button and adds a listener that monitors the current page and zoom:
loadFlashPaper("MyFlashPaperDocument.swf",
fp_mc,
fp_mc._width,
fp_mc._height,
loadNotifier);
You can modify a few initial settings for Flash documents without using ActionScript;
instead, you override some settings in the URL of your SWF file, as follows:
foo.swf?INITIAL_VIEW=35&POPUP_ENABLED=false
In this example, the document is created with an initial zoom of 35%, and with the
Open In New Browser buttonhidden.
UIFONT Name of the font to use for the FlashPaper user interface.
UIFONTSIZE Sizes to use for Normal fonts in the FlashPaper user interface.
UISMALLFONTSIZE Sizes to use for Small fonts in the FlashPaper user interface.