下载官方的源码:
地址: http ://flexpaper.googlecode.com/svn/trunk/
我修改的是flex 3 版本的. 其实4也差不多.对应的修改就可以了
1. 源码部署需要修改相关参数. 根据你的实际flex sdk 环境有关. 如果没必要多语言支持.就全都删除了.只保留中文的FlexPaper.properties 即可. 放到src 根目录下
2. 设置flash player 为10.0.0 或以上. 这个是为了解决 运行示例程序出现 右键菜单不能访问clipboardMenu属性 和 unloadAndStop 方法的问题
3. 默认官方的源码是有点问题的. 他设置的加载swffile 时间不对. 照成了 一直是在加载文件状态.pdf 打不开的情况.
修改方式如下.:
- FlexPaperViewer.mxml
<fp:Viewer id="paper1" onDocumentLoaded="documentLoadedHandler(event)"
onDocumentLoading="papersLoadingHandler(event)"
onDocumentLoadedError="documentLoadedErrorHandler(event)"
onLogoClicked="logoClickedEventHandler(event)"
onNoMoreSearchResults="onNoMoreSearchResultsHandler(event)"
onLoadingProgress="onDocumentLoadingProgressHandler(event)"
onScaleChanged="onScaleChanged(event)"
onFitModeChanged="onFitModeChanged(event)"
onViewModeChanged="onViewModeChanged(event)"
onCurrPageChanged="onCurrPageChanged(event)"
onCursorModeChanged="onCursorModeChanged(event)"
onExternalLinkClicked="onExternalLinkClickedHandler(event)"
onDocumentPrinted="documentPrintedHandler(event)"
onPageLoaded="pageLoadedEventHandler(event)"
onPageLoading="pageLoadingEventHandler(event)"
onErrorLoadingPage="errorLoadingPageEventHandler(event)"
SwfFile="{SwfFile}"
Scale="{Scale}"
ZoomTransition="{ZoomTransition}"
ZoomTime="{ZoomTime}"
FitPageOnLoad="{FitPageOnLoad}"
FitWidthOnLoad="{FitWidthOnLoad}"
ProgressiveLoading="{ProgressiveLoading}"
ZoomInterval="{ZoomInterval}"
MinZoomSize="{MinZoomSize}"
MaxZoomSize="{MaxZoomSize}"
SearchMatchAll="{SearchMatchAll}"
SearchServiceUrl="{SearchServiceUrl}"
EncodeURI="{EncodeURI}"
AutoAdjustPrintSize="{AutoAdjustPrintSize}"
PrintPaperAsBitmap="{PrintPaperAsBitmap}"
addedToStage="MacMouseWheelHandler.init(stage)"
creationComplete="viewerCreationCompleteHandler(event)"
height="100%" width="100%" borderStyle="solid" tabIndex="0" />
SwfFile="{SwfFile}" 这个属性删除掉
增加 初始化完成事件
creationComplete="viewerCreationCompleteHandler(event)"
方法如下:
protected function viewerCreationCompleteHandler(event:FlexEvent):void
{
loadSwf(SwfFile);
}
然后继续修改
- FlexPaperViewer_Base.mxml 的 412 行左右的
public dynamic function loadSwf(s:String):void{
viewer.SwfFile = s;
}
方法 改成
public dynamic function loadSwf(s:String):void{
viewer.loadSwfFile(s);
}
然后继续修改
- Viewer.as 585行
public function set SwfFile(s:String):void {
改成
public function loadSwfFile(s:String):void {
这样就可以在调用mxml 文件中这样写了:
<flexpaper:FlexPaperViewer id="flexview" width="100%" height="100%"
Scale="0.95" SwfFile="http://localhost:8080/PdfView/view/Paper.swf" />
或者 手动加载文件
flexview.loadSwf("http://localhost:8080/PdfView/view/Paper.swf");
都可以显示了
如图:

本文详细介绍了如何通过调整FlexPaper源码来解决运行示例程序时遇到的问题,包括修改参数、设置FlashPlayer版本、解决加载swffile时间问题等,并提供了代码示例和调整建议。
7720

被折叠的 条评论
为什么被折叠?



