FlashPaper 播放器定制:
原理就是先创建一个空影片剪辑,再把FlashPaper的.swf文件loadMovie进来,然后再对loadMovie进来的东西进行控制。代码如下(不缩放自适应,隐藏了LOGO、打印、源SWF访问):
Stage.align = "TL";
Stage.scaleMode = "noScale";
function hideBrand () {
if (paper.gMainView.m_numPagesLoaded) {
paper.toolbar_mc.brandClip_mc.swapDepths(1000);
paper.toolbar_mc.brandClip_mc.removeMovieClip();
paper._x=0;
paper_y=0;
paper.setSize (Stage.width, Stage.height);
clearInterval (hideBrandInterval);
}
}
function hidePrint () {
if (paper.gMainView.m_numPagesLoaded) {
paper.toolbar_mc.controls_mc.print_mc.swapDepths(1000);
paper.toolbar_mc.controls_mc.print_mc.removeMovieClip();
paper._x=0;
paper_y=0;
paper.setSize (Stage.width, Stage.height);
clearInterval (hidePrintInterval);
}
}
function hidePopup () {
if (paper.gMainView.m_numPagesLoaded) {
paper.toolbar_mc.controls_mc.popup_mc.swapDepths(1000);
paper.toolbar_mc.controls_mc.popup_mc.removeMovieClip();
paper._x=0;
paper_y=0;
paper.setSize (Stage.width, Stage.height);
clearInterval (hidePopupInterval);
}
}
createEmptyMovieClip ("paper", 1);
paper.loadMovie("flashplaypdf-swf/"+_root.id+".swf"); //其中_root.id为参数读取
//禁止内容缩放
fullscreen = new Object();//创建类
fullscreen.onResize = function() {//swf大小改变时触发
paper._x=0;
paper_y=0;
paper.setSize (Stage.width, Stage.height);
//顶和左对齐
//paper._x = Stage.width-300;//根据Stage.width和Stage.height获得的舞台的宽和高来调整显示
//paper._x=System.capabilities.screenResolutionX;
//paper_y=System.capabilities.screenResolutionY;
};
Stage.addListener(fullscreen);
hideBrandInterval = setInterval (hideBrand, 1);
hidePrintInterval = setInterval (hidePrint, 1);
hidePopupInterval = setInterval (hidePopup, 1);
注:工具栏参考——["panTool_mc", "selectTool_mc", "divideTools_mc", "find_mc", "divideZoom_mc", "zoom_sld", "currZoom_mc", "fitPage_mc", "fitWidth_mc", "dividePager_mc", "currPg_mc", "numPgs_txt", "prevNext_mc", "dividePrint_mc", "print_mc", "popup_mc", "hiddenToolsBtn_mc"]
FlexPaPer播放器定制:
先从http://flexpaper.googlecode.com/svn/trunk/下载FlexPaPer源代码,定制开发后,编译为FlexPaper.swc
新建Flex项目“FlexPlay”,导入FlexPaper.swc,编辑FlexPlay.mxml,输入如下代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:fp="com.devaldi.controls.flexpaper.*"
layout="absolute" width="100%" height="100%"
applicationComplete="initApp();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
public var _aid = 0;//文档ID
[Bindable]
public var _Scale:Number = 1;//缩放比例
[Bindable]
public var _SwfFile:String = "";//SWF文件路径
[Bindable]
public var _ZoomTransition:String = "easeOut";
[Bindable]
public var _ZoomTime:Number = 0.6;
[Bindable]
public var _ZoomInterval:Number = 0.1;
[Bindable]
public var _FitPageOnLoad:Boolean = false;//加载后适合高度
[Bindable]
public var _FitWidthOnLoad:Boolean = false;//加载后适合宽度
[Bindable]
public var _PrintEnabled:Boolean = false;//是否支持打印
[Bindable]
public var _FullScreenAsMaxWindow:Boolean = false;//是否支付全屏
[Bindable]
public var _ProgressiveLoading:Boolean = false;//是否延迟加载
[Bindable]
public var _localeChain:String = "zh_CN";//语言
private var isFocus:Boolean = false;
//初始化参数
private function initApp():void{
var params:Object = Application.application.parameters;
_Scale = getNumber(params, "Scale", 1);
_SwfFile = getString(params, "SwfFile", "Paper.swf");
_ZoomTransition = getString(params, "ZoomTransition", "easeOut");
_ZoomTime = getNumber(params, "ZoomTime", 0.6);
_ZoomInterval = getNumber(params, "ZoomInterval", 0.1);
_FitPageOnLoad = getBoolean(params, "FitPageOnLoad", false);
_FitWidthOnLoad = getBoolean(params, "FitWidthOnLoad", false);
_PrintEnabled = getBoolean(params, "PrintEnabled", false);
_FullScreenAsMaxWindow = getBoolean(params, "FullScreenAsMaxWindow", false);
_ProgressiveLoading = getBoolean(params, "ProgressiveLoading", true);
_localeChain = params["localeChain"];
//注册事件监听
this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
//开放给外部(javascript)调用
ExternalInterface.addCallback("hasFocus", hasFocus);
//ExternalInterface.addCallback("focus", focus);
ExternalInterface.addCallback("setViewerFocus", setViewerFocus);
}
private function onMouseOver(event:MouseEvent):void{
this.isFocus = true;
}
private function onMouseOut(event:MouseEvent):void{
this.isFocus = false;
}
public function hasFocus():Boolean{
//Alert.show("hasFocus");
return isFocus;
}
public function setViewerFocus(isFocus:Boolean):void{
//Alert.show("setViewerFocus");
this.paperViewer.setViewerFocus();
}
/**
*
* 获取String类型参数
* 如果没有,则返回默认值
**/
private function getString(params:Object, name:String, def:String):String{
if(params[name] != null){
return params[name];
}
return def;
}
private function getNumber(params:Object, name:String, def:Number):Number{
if(params[name] != null){
return params[name];
}
return def;
}
private function getBoolean(params:Object, name:String, def:Boolean):Boolean{
//Alert.show("比较:"+name);
if(params[name] != null){
return params[name] == "true";
}
return def;
}
]]>
</mx:Script>
<!--mx:Panel x="165" y="76" width="250" height="200" layout="absolute" title="chaishen10000">
<mx:Label x="59" y="37" text="{Scale}" width="88"/>
</mx:Panel-->
<fp:FlexPaperViewer id="paperViewer"
width="100%"
height="100%"
Scale="{_Scale}"
SwfFile="flexplaypdf-swf/{_SwfFile}"
ZoomTransition="{_ZoomTransition}"
ZoomTime="{_ZoomTime}"
ZoomInterval="{_ZoomInterval}"
FitPageOnLoad="{_FitPageOnLoad}"
FitWidthOnLoad="{_FitWidthOnLoad}"
PrintEnabled="{_PrintEnabled}"
FullScreenAsMaxWindow="{_FullScreenAsMaxWindow}"
ProgressiveLoading="{_ProgressiveLoading}" />
</mx:Application>
注意:源代码中的“/styles/default.css”样式“.viewerBackground ”改为:
.viewerBackground {
backgroundImage: ClassReference("com.devaldi.skinning.GradientBackground");
backgroundSize: "100%";
fillColors: #aab3b3, #d5dddd;
fillAlphas: 1, 1;
borderColor: #8a8a8a;
backgroundColor: #d5dddd;
}