You are on page 1of 9

Hacking Flash Paper to Make it Work for You

I haven't worked with Flash Paper a lot but seems like we are starting to use it more at work. A
client had this nice technical illustration that he wanted transformed into Flash Paper. The
illustration was huge so when it was zoomed out it looked bad. I looked around and found that
there is a Flash Paper API. This provided some nice features such as controlling the zoom, etc...
That worked nicely but I need to find a way (once zoomed in) to reposition the "page". I couldn't
find anything readily so I dug through the objects with loops and found a way. I thought I'd share
this find.

While I'm on a Flash Paper kick I guess I'll post this technote about getting a Landscape Flash
Paper.

The code below uses code written by Damian Taggart to interface an swf wrapper which loads
the Flash Paper swf file and then uses the API included within it to modify the document - from
DevMX.

Stage.scaleMode = "noScale";

Stage.align = "TL";

stop();

/* loading a Flash Paper document by damian taggart


protoype loadFlashPaper:

([path to Flash paper .swf, destination mc,width, height, optional: obj to recieve notification
when loading completes])

*/

var pathToSWF = "myFlashPaper.swf";

var destMC = this.createEmptyMovieClip("load_mc",this.getNextHighestDepth());

var wide = Stage.width;

var tall = Stage.height;

var notifyObj = destMC.getIFlashPaper();

function loadFlashPaper(pathToSWF, destMC, wide, tall, notifyObj) {

trace(pathToSWF);

var intval = 0;
var loadFP = function () {

destMC._visible = false;

var fp = destMC.getIFlashPaper();

if (!fp) {

trace("not loaded");

return;

}else if (fp.setSize(wide, tall) == false) {

trace("not yet loaded");

return;

}else {

destMC._visible = true;

clearInterval(intval);

onLoaded(fp);

intval = setInterval(loadFP, 100);

destMC.loadMovie(pathToSWF);

// change the FP control bar

function onLoaded(fp) {

trace("UI changes called");

fp.enableScrolling(true)

fp.setSize(Stage.width,Stage.height);
fp.setCurrentZoom(186);

for(c in fp.m_mainMC.document_mc){

trace("c" + c);

fp.m_mainMC.document_mc.y_sb.m_scrollPosition = 180;

fp.m_mainMC.document_mc.x_sb.m_scrollPosition = 20;

loadFlashPaper(pathToSWF, destMC, wide, tall, notifyObj);

As you can see it was two measly lines that go and reference the scrollbars and set the positions.

fp.m_mainMC.document_mc.y_sb.m_scrollPosition = 180;
fp.m_mainMC.document_mc.x_sb.m_scrollPosition = 20;

You can do the same by hitting the mc that is scrolled (just do some for in loops - you'll find it)
and repositioning it - just keep in mind this screws scrollbars up so I don't advise this unless you
have the scrollbars shut off.

Hope this helps.


-Sarge

2:18 PM | Permalink
26 comments
thx for the link back ;-)

Posted by damian | 11:05 AM


I thought this function was written by Kendall Whitehouse

http://www.macromedia.com/devnet/flashpaper/articles/import_flpaper2.html

Posted by Anonymous | 11:39 AM


The code is similar but it is not the same exactly - I mentioned that I got the code from damian
cause that's where I found it. So thanks to him for posting it and to you for pointing us to the
DevNet article!
Posted by Sarge | 11:43 AM
How would you load the flashpaper document into a Flash Window component?

I've tried something like this but it doesn't work:

var blah = mx.managers.PopUpManager.createPopUp(_root, mx.containers.Window, true,


{title:"Insert title Here",closeButton:true, contentPath:destMC});
blah.setSize( 500,320 );

dest_mc being the emptymovieclip that was created in Damian's example. :)

Posted by Anonymous | 11:46 AM


I think you are looking for something more like this:

var blah = mx.managers.PopUpManager.createPopUp(_root, mx.containers.Window, true,


{title:"Insert title Here",closeButton:true, contentPath:"my.swf"});
blah.setSize( 500,320 );

Using an event to capture the loaded clip load will then allow you to modify the loaded swf
(flash paper in this case) as above with some minor code modifications.

Posted by Sarge | 1:32 PM


Thanks, but what I'm running into is that if I just load the Flashpaper swf by using the above, it
doesn't allow me to resize the Flashpaper swf...it only allows me to resize the popup window.
The flashpaper swf remains fixed.

So I thought maybe I could designate the popup window to load the movieclip that has the
flashpaper swf embedded in it. That would, in theory, allow me to resize the flashpaper
document.

Posted by Anonymous | 2:34 PM


Correct- if instead of targeting the flash paper swf target your custom flash paper wrapper swf. If
the above code you will need to modify some references potentially but I'm sure you will be able
to figure it out from there. Hope that helps.

Posted by Sarge | 2:37 PM


Ok - I took a look.
1) Instead of targeting your flash paper swf to load into the Window component target your
custom Flash Paper wrapper (using the code above).

2) In the wrapper fla switch these lines to this:

....
function onLoaded(fp) {
trace("UI changes called");
fp.enableScrolling(true)
//not stage size but the
//size of the flsh paper
//window you desire
fp.setSize(150,150);
....

3)Now when you run the main FLA with the Window component and load the wrapper swf your
flash paper should be sized accordingly.

You could probably do the same by listening for the load event on the window component and
attempting to modify the variable "fp" by referencing it from your _root FLA. I don't like the
window component so I avoided that...

Hope this does it.

Posted by Sarge | 2:46 PM


Aieeee! I never thought to first export the resulting swf and then load that into the window
component. I was trying too hard to load everything all in one .FLA.. Thanks for the
suggestion! :)

Posted by Anonymous | 2:51 PM


I'm hoping that you might be able to help me. How does one go about removing the print-button
icon from the FlashPaper interface? I've looked at all of the documentation at
http://www.macromedia.com/support/
documentation/en/flashpaper/2/flash
paper_api/flashpaper_api3.html. I'm not understanding what modifications/what files they are
discussing.
I have an instance where I'm calling a FlashPaper document into my HTML using the tag: a
href="document.swf" target="_self" The reason for wanting to remove the print button is so that
the document user will always need to use the print function(s) native to I.E.
Thanks for considering my question.

Posted by Anonymous | 8:42 PM


You will need to create a wrapper swf file as mentioned in my post
(http://pixelfumes.blogspot.com/2005/07/hacking-flash-paper-to-make-it-work.html).

The wrapper will load the flash paper swf into itself and then make the api call function
showPrintUI( flag ) see here:
http://www.macromedia.com/support/documentation/en/contribute/2/flashpaper_api/flashpaper_
api03.html

That should remove the print button. Hope that helps.

-Sarge
Posted by Sarge | 9:12 PM
gracias por el scrip me ayudo mucho, gracias tio!

Thanks for the script it help me a lot, thanks dude!

Posted by Jose Fuertes Salazar | 5:08 PM


No problem man! Glad to help.
-Sarge

Posted by Sarge | 8:25 AM


Hello,

Checkout http://www.zanzibarfiction.com

We sell FlashPaper Interface Plugins from only $30.


You can choose No Print, or No Select Button.

We also provide Author Link subscription service (top right-hand


button).
Furthermore, you can also choose your own color scheme FREE of CHARGE.

Zanzibar Fiction (TM) - FlashPaper Interfaces & Author Link Service


http://www.zanzibarfiction.com

Posted by Anonymous | 11:27 AM


I have a question, pls help me.
I am generating a popup thru actionscipt:
myTW = mx.managers.PopUpManager.createPopUp(_root, mx.containers.Window, false,
{closeButton: true, title: _root.reqmessage1, _width: 610, _height: 232, _x: 120, _y: 240, color:
16711680,contentPath:radioButtonArray[_loc2].object.bkimage});
where,
bkimage represents any img/swf which comes from an xml file. Now, i have already specified
the width& height in the properties. But, when the image is bigger or smaller, i would like to
have the popup scale itself accordingly. What changes do i make to the script?

Posted by skmystery | 3:13 AM


You probably would need to monitor events for the window creation
(http://livedocs.macromedia.com/flash/mx2004/main_7_2/00003038.html#3165489). Once the
window has been loaded you can then modify the width/height based on the loaded image. If this
method doesn't work you will have to watch the load of the external swf/image using any method
you like (onEnterFrame, etc) to check for the load in the window and then resize based on the
size. I don't often use this component as I find it hard to reference such things and manage the
depths of the created windows. Hopefully I pointed you into somewhat of a good direction...
Posted by Sarge | 6:57 AM
Hi there,

I've been trying out the function of function showPrintUI (false), and can't figure out how to
make it work, I'm a beginner in Flash, can you please help me?

Thanks,

Posted by Anonymous | 7:34 AM


I was wondering if you have any experience attaching movie clips from the library into the flash
paper movie clip. I wanted to load my own graphics into some of the UI stuff, like replace that
pesky macromedia logo. However after many hours of trying different things Im starting to
believe that flash has some how made impossible to attachMovie to the inside of a flash paper. Is
there some security feature that I dont know about? Here is the command I use (holder_mc being
the loaded flash paper...and the fp is fully loaded)...

this.holder_mc.toolbar_mc.attachMovie("Fcover", "brandClip_mc",
this.holder_mc.toolbar_mc.brandClip_mc.getDepth());

as you may know you can disable the logo with


holder_mc.toolbar_mc.brandClip_mc._visible = false;

but you can't replace it, at least that is how it appears to me.

Posted by Anonymous | 4:16 AM


I'm fairly certain this is an OLD blog post, but I just now heard of Flash Paper and I have a
problem :(

I wanted to use it to submit some writing of mine to a site that is basically an art community. The
only problem is that the player is too small, and I don't know how to resize it (using the embed
code is not an option as I don't have any control over that)

So I came across this article and I did a little research. Forgive me if I'm misunderstanding this,
but, doesn't this just load a .swf file that is elsewhere on the computer?

I mean, if I had my own website this wouldn't be a problem as I'd also upload that separate .swf
file to the same directory or whatever. Isn't there any way at all to merge the two documents into
one that loads and is resized/etc?

I apologize if I confused anyone, because I'm not too sure how to explain this...

Posted by IanSquall | 7:48 PM


Ian, yes this is an old blog post but it is still pertinent. This does what your were imaging.
Basically takes and pulls the flash paper swf into another swf and then uses actionscript to make
calls against the flash paper swf file. So if you need to have control when this is uploaded
somewhere you might be out of luck. Can you point me to where you are attempting this - maybe
I can take a look.
Thanks.

Posted by Sarge | 8:38 PM


Sarge, thanks for the response. :)

I kind of assumed I was out of luck :( I wish the actual flashpaper application had size/dimension
settings instead >_<

Anyway, this is the place I'm referring to: link

Posted by IanSquall | 5:25 PM


Is it possible to link to a local file on a cd from flash paper. I'm going from word, where I setup
the link, then save out a pdf, then make flash paper. but when i have the flash paper in the flash
interface and click on the link, it always adds a http:// at the front of the link. I just want to link to
local file on a cd such as pdf/test.pdf with no http:// in front....is this possible?

Posted by Anonymous | 10:22 AM


Heya Sarge,

Thanks for the code, really helping to get a grip on FlashPaper. However, I do have a question
which I would love help with...

Long story short, I just want to get the page movieclips into their own seperate swfs. I don't need
any of the extra functionality FP adds, just the converted PDF pages. I see I can access the pages
at fp.m_mainMC.document_mc.pages_mc.page1_mc etc, but how would I get a page into a
seperate swf on its own?

Any response would be greatly appreciated mate, Mark.

Posted by MakingMeMark | 4:17 AM


Any ideas on how to make the scroll bars disappear all together? I've disabled scrolling
(enableScrolling(false)) but the scrollbars are still there, even though the user can't scroll. Cheers.

Posted by Pat | 5:59 PM


found a service http://www.pdftube.com wich autogenerates flashpapers from linked pdf-files.
great on http://www.itwgema.ch the only link a pdf and pdftube will convert and shows up the
flashpaper

Posted by Anonymous | 8:04 AM


Hello!

Can someone help me with this? I need to import a flash paper swf from INSIDE my main swf
and it just wont work. I can see the images but cant see anything more. need help really quick
plz!

You might also like