Professional Documents
Culture Documents
In this tutorial, you'll learn how to build Flash movies that can load external FlashPaper 2 SWF files.
This technique enables you to control the context of your FlashPaper viewing environment without using
traditional layout tags in an HTML page. If you're building a Flash application, a Flash-based CD-ROM,
or a Flash-based web site, contextualizing the experience of viewing printed documentation within your
own user interface reduces the dependency of launching a new browser window to view another
document type, such as HTML or PDF. Recently, I used FlashPaper 2 documents as a replacement for
PDF previews within a Flash-based CD-ROM project for a university medical department. Previously,
the department had used a "text-only" version of linked PDF documents within the Flash CD-ROM as a
preview; now, they're able to distribute exact reproductions of the documents as FlashPaper directly
within the CD-ROM interface.
If you haven't used FlashPaper and want to know more about the benefits of using FlashPaper for document
distribution on the web, read the FlashPaper articles by CMX partner, Kim Cavanaugh. Specifically, you may want to
read the article titled "What's New in FlashPaper 2" (http://www.communitymx.com/content/article.cfm?page=3&cid=D6366)
.
In this section, you'll learn how to load a FlashPaper 2 SWF file into another Flash movie. This basic
procedure enables you to use the default view size, 550x400, of a FlashPaper 2 document within another
movie.
When you load a FlashPaper 2 document into another Flash movie, the default size of that loaded doc is 550x400.
However, if you run FlashPaper 2 documents directly in the standalone (SA) Flash Player, the default document view
snaps to the size of the first page of the document.
Before you proceed with the following steps, download the support files for this tutorial and extract the
Distributing_Classes_in_SWC_Files.swf file. This Flash movie is a FlashPaper 2 document, created
from a previous article (http://www.communitymx.com/abstract.cfm?cid=DC2C0) I wrote for Community MX.
! "
# $ %
& '
% loa dMovie () %
( $ ) $ *
1 of 7
& % ' + , $
, +
5 " -. -. /
0
$ 1
+ $ 223
433 $
WARNING: If you use a Mask layer on a clip that contains a loaded FlashPaper document, the textfields of the
FlashPaper controls will not display because they use device fonts. If you need to mask a clip containing a loaded
FlashPaper document, make sure you create a dynamic mask in ActionScript, and mask the parent clip of the
FlashPaper document with the Mov ieClip .setMa sk() method.
2 of 7
Setting the Size of the FlashPaper View
In order to control the viewing area of a FlashPaper document, you need to invoke the s et S iz e ()
method of the loaded FlashPaper document. The viewing area is defined as that taken up by the control
bar at the top of the FlashPaper document and the scrollpane below the bar containing the actual
document view. In this section, you'll learn how to use the MovieClipLoader class along with the
M ov i eC l ip . on E nt e rF r am e () handler to invoke the s et S iz e () method of the FlashPaper document.
! "
$ (
6 & $
/ $ onL oadIni t() %
onE nterFr ame() set Size()
/ set Size() +
$ $ 233 533
% onE nterFr ame() ' $
NOTE: Unfortunately, the set Size() method of the FlashPaper document is not yet declared when the
onL oadIni t() method of the MovieClipLoader listener is fired. We have to use an onE nterFr ame() or equivalent
operation to keep checking the loaded FlashPaper doc, as mcDoc, until the set Size() method is initialized.
// cr eat e t he Mov ieC lip Loa der in sta nce an d add the
// cu rre nt tim eli ne as a l ist ene r
va r m cl: Mov ieClip Loa der = new Mo vie Cli pLo ader();
mc l.a ddL ist ene r(t his );
3 of 7
5 " / +
set Size() $
You may notice the FlashPaper logo flash just before the document viewer is resized. You can set the _vi sible
property of the mcDoc to false at the start of the movie, and then set it back to true after the set Size() method is
invoked.
In this last section, you'll learn how to display a FlashPaper 2 document in an instance of the Window
component. The Window component will act as a draggable document viewer within your Flash movie.
Before you build the Flash document, let's review the procedure that you'll employ to create the
document viewer:
% ( 0 % ' (
onD ocClic k /
% ) ' $
'
5 / ) +
onW indowL oad onE nterFr ame() set Size()
+ / set Size() +
+ /
)
4 / ( ' $ /
onW indowC lick() ( % del etePop Up()
/ $
Now that you have an idea of the procedure, you're ready to start building the Flash document.
4 of 7
"
! ) $ 0
$ *
$ '
5 ) $ / $
) $ 1 /
' , ' ' "
4 "
$5 % 0 /
$ ' $ $
The code in this listing uses the Delegate class included with the 7.2 updater for Flash MX 2004. For more information
on using the Delegate class, read Joey Lott's article, "Dealing with Scope - Using Delegate."
(http://www.communitymx.com/abstract.cfm?cid=B36DF)
5 of 7
im por t m x.u til s.D ele gat e;
// se tup a cal lba ck for th e B utt on ins tan ce's click e ven t
va r o nDo cCl ick :Fu nct ion = fun cti on( oEv ent :Object):Voi d {
var oW ind owI nit :Ob jec t = {
t itl e: "Do cum ent Vi ewe r",
c ont ent Pat h: sFP Doc ,
c los eBu tto n: tru e
};
cwi Doc = mx. man age rs. Pop UpM ana ger .createPopUp
(t his , m x.c ont ainers .Wi ndo w, tru e, oWindowIn it) ;
cwiDoc .ad dEv ent Lis ten er( "co mpl ete ", Delegate. cre ate
(t his , t his .on Window Loa d)) ;
cwiDoc .ad dEv ent Lis ten er( "cl ick ", Delegate.cre ate
(t his , t his .on Window Cli ck) );
cwiDoc .se tSi ze( 500 , 3 50) ;
};
// In vok e the onD ocC lic k() fu nct ion wh en the View Doc bu tto n is clicked
cb t.a ddE ventLi ste ner ("c lic k", De leg ate .cr eate(this, t his .on DocClick));
2 " / ( 7 ) ' /
) )
/ $ 4 / (
' $
6 of 7
Figure 3 The Window-enabled FlashPaper document viewer
If you'd like to take this example further, try adding a List or ComboBox component which controls the document URL
used by the Window component. You could create a virtual library of all your FlashPaper documents, browsing them
within your own Flash interface. In a future CommunityMX article, I'll show you how to create a ColdFusion
component that retrieves a list of FlashPaper document URLs and displays them in a List component for browsing.
Conclusion
You now know how to utilize FlashPaper documents within your own Flash movies. Using the
techniques outlined in this tutorial, you can effectively add document viewing capabilities to your Flash
presentations and applications.
Keywords
FlashPaper, loadMovie, MovieClipLoader, Window component
8 &9 33 : 334 $
7 of 7