Macromedia Studio 8 shipped with Macromedia FlashPaper 2.0, a pretty cool app that will take PDF and other documents and convert them into .swf files that you can load into other flash/swf applications.
The following is a quick tutorial on how to load FlashPaper swf files into Flash applications in ActionScript 2.0.
This tutorial assumes that you know the basics of FlashPaper 2.0 and have a usable FlashPaper .swf file.
Essentially, you will include an ActionScript file that will provide the functions to allow you to load in and scale the FlashPaper .swf and then include a few configurations and lines of code to load in the FlashPaper .swf.
First, create a new ActionScript file, save as "flashpaper.loader.as" and copy and paste the following code into it:
function loadFlashPaperSWF( arg_flashPaper_conf:Object ):Void{
trace( "\nFrom loadFlashPaperSWF" );
trace( "arg_flashPaper_conf.flashPaper_SWF " + arg_flashPaper_conf.flashPaper_SWF );
// Creating the MovieClip into which we’ll load our Flash Paper document.
this.createEmptyMovieClip( "testMovie_mc", this.getNextHighestDepth() );
// callback functions for this clip
var mcObjListener = new Object();
mcObjListener.onLoadComplete = function(){
testMovie_mc._visible = false;
}
mcObjListener.onLoadInit = function( arg_target:MovieClip ):Void{
trace( "running the onLoadInit callback" );
trace( "arg_target = " + arg_target );
// We’ll have to wait until the first page of the flash paper document has loaded
// before we have access to the FlashPaper API
// To do so, we’ll set up an interval that will check for it’s existence.
// Then run the setSize method
var var_intervalID = 0;
// Our check function
function checkFlashPaperLoaded(){
// Hide the holder clip until it is loaded
// eval( arg_target )._visible = false;
// Getting a reference to our FlashPaper object
var var_flashPaperObj = eval( arg_target ).getIFlashPaper();
trace( "var_flashPaperObj = " + var_flashPaperObj );
if( !var_flashPaperObj ){
return;
}
else{
trace( "We now have access to our FlashPaper API" );
clearInterval( var_intervalID );
// Resize the doc to fit the size of the stage
var_flashPaperObj.setSize( arg_flashPaper_conf.flashPaper_width,
arg_flashPaper_conf.flashPaper_height );
// Setting the document to fit to height:
// var_flashPaperObj.setCurrentZoom( "page" );
// Show it
eval( arg_target )._visible = true;
}
}
var_intervalID = setInterval(checkFlashPaperLoaded, 100);
};
// Here we create a new MovieClipLoader Object
var var_movieClipLoader = new MovieClipLoader();
// Here we add the listener to our new MovieClipLoader Object
var_movieClipLoader.addListener( mcObjListener );
// Now we use our new MovieClipLoader object to load the swf into the movieclip holder
var_movieClipLoader.loadClip( arg_flashPaper_conf.flashPaper_SWF, "testMovie_mc" );
}
Then, create a new Flash file (ActionScript 2.0) and add the following to the first frame of the timeline:
#include "flashpaper.loader.as"
// ============================================================================
// Configurations:
//
// Our config object
var obj_flashPaper_conf:Object = new Object();
// The flash paper swf to load:
obj_flashPaper_conf.flashPaper_SWF = "files/flashpaper_docs/flashpaper.swf";
// The width and height of our flashpaper doc
obj_flashPaper_conf.flashPaper_width = 650;
obj_flashPaper_conf.flashPaper_height = 320;
// ============================================================================
// Loading our Flash Paper SWF
loadFlashPaperSWF( obj_flashPaper_conf );
Edit the configurations to specify the location of the FlashPaper .swf and the size that you want it to be displayed and you are good to go.