Code
// Main application loadFp. mxml
<! -- L version = "1.0" encoding = "UTF-8 -->
// Main application loadFp. mxml
// Flash cs3code to generate the fpl.swf
Import flash. display. Stage;
Stage. align = "LT ";
// Stage. scaleMode = "showAll ";
Var url = "template.swf ";
Var fp;
// LocalConnection Communication Interface
Var caller: LocalConnection = new LocalConnection ();
Var sender: LocalConnection = new LocalConnection ();
Caller. connect ("_ flashpaperloader ");
Caller. allowDomain ("*");
Sender. allowDomain ("*");
Security. allowDomain ("*");
// Settings page
// Caller. setPage = function (n: Number)
//{
// FP. setcurrentpage (N );
//}
// Set the size
Caller. setpapersize = function (W: Number, H: Number)
{
Trace ("fploader width =" + W + "Height =" + H );
FP. setsize (W, H );
}
// Set Scaling
// Caller. setcurrentzoom = function (ZOOM: Object)
//{
// FP. setcurrentzoom (zoom );
// Sendcurrentzoom ();
//}
// Set the next page
// Caller. nextpage = function ()
//{
// Var P: Number = FP. getcurrentpage ();
// If (p + 1 <= FP. getnumberofpages ())
// FP. setcurrentpage (p + 1 );
//}
// Set the previous page
// Caller. prePage = function ()
//{
// Var p: Number = fp. getCurrentPage ();
// If (p-1> 0)
// Fp. setCurrentPage (p-1 );
//}
// Uninstall
Caller. unload = function ()
{
Caller. close ();
Caller = null;
Sender = null;
Fp. destroy ();
Fp = null;
UnloadAndStop ();
Paper. unloadMovie ();
Paper = null;
}
// Function: loadFlashPaper
//------------------------
// Load FlashPaper document, size it,
// Parameters:
// Path_s: Path of SWF to load
// Dest_mc: Movie clip to hold the imported 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
Function loadFlashPaper (path_s, dest_mc, loaded_o ){
Var intervalID = 0;
Var loadFunc = function (){
Trace ("loading starts ....");
Dest_mc. _ visible = false;
Fp = dest_mc.getIFlashPaper ();
If (! Fp ){
Return;
} Else if (! Fp. setSize (0, 0 )){
Trace ("no window size set ");
Return;
} Else {
Trace ("flashpaper loaded successfully ");
Clearinterval (intervalid );
// Var pages_ I = fp. getNumberOfPages ();
// Paper. toolbar_mc.brandClip_mc.swapDepths (1000 );
// Paper. toolbar_mc.brandClip_mc.removeMovieClip ();
// CtrlHolder_mc.swapDepths (_ root. control_mc );
Dest_mc. _ visible = true; // now show the document
// _ Root. control_mc. _ visible = true; // now show the Controller
Loaded_o.onloaded (FP );
}
}
IntervalID = setInterval (loadFunc, 100 );
Dest_mc.loadMovie (path_s );
}
// Function: onLoaded ()
//------------------------
// Called once loading is complete
// Parameters:
// Fp: FlashPaper interface (returned by getIFlashPaper ())
Function onLoaded (){
// We can now call the FlashPaper API functions.
// Remove the standard user interface features:
// Fp. showUIElement ("PrevNext", false );
Fp. showUIElement ("Print", false );
// Fp. showUIElement ("Find", false );
// Fp. showUIElement ("Tool", false );
// Fp. showUIElement ("Pop", false );
// Fp. showUIElement ("Zoom", false );
// Fp. showUIElement ("Page", false );
// Fp. showUIElement ("Overflow", false );
// Fp. enableScrolling (false );
// Some additional API features (here commented out ):
FP. setcurrentzoom (100 );
// Sendcurrentzoom ();
Sender. Send ("_ flexloader", "fploaded ");
}
// Hide the navigation Controller until after the document is loaded:
// _ Root. control_mc. _ visible = false;
// Create movie clip to hold the document:
Var paper = this. createEmptyMovieClip ("paper", 100 );
// Create movie clip to exchange the depth with the navigation controller clip:
// Var ctrlHolder_mc = this. createEmptyMovieClip ("ctrlHolder", 200 );
// Position the document clip on the stage:
Paper. _ x = 0;
Paper. _ y = 0;
// Load the FlashPaper document:
LoadFlashPaper (url, paper, this );