標籤:style class blog code java http
1.首先下載FlexPaper的源碼。
2.本人不懂flash,只是百度下,然後自己瞎弄弄的。我用的flash build 4.5
提供個key:1499-4181-9296-6452-2998-3656
首先在flash build中建立一個flex項目,第一步填寫項目名稱-flexpaper,第二步直接預設,最後一步需要注意下。
選擇合并到代碼中,要不然你的bin-debug目錄下面會出現很多其他的swf檔案
然後把你1步下載下來的源碼解壓。
把這三個目錄全部複製到你剛才建立的flex項目根目錄下。最後結果是這樣的:
然後點擊項目的屬性,將附加的編譯參數修改成如下所示,-source-path=locale/{locale}
功能表列中文顯示:
右鍵項目--->屬性---->Flex編譯器--->在附加的編譯器參數框裡加入下面一句:-locale zh_CN -source-path=locale/{locale} -keep-all-type-selectors=true即可。
我記得這些全部完成以後,好像有個檔案一處會有錯誤,如果出錯檔案前面會有個紅×,右鍵項目屬性,選擇Flex編譯器,勾選“使用Flex 3 相容模式”
修改:
1.右上方有一個FP,點擊以後出現about
找到如下所示的檔案:
開啟,搜尋bttnInfo,一共就三句,全部注釋掉。然後在run,就會發現右上方的FP沒了。(print也是在這個檔案裡面修改的,大家自己看看吧)
2.修改右下角的logo,如下
找到如下檔案,開啟,找到createDisplayContainer這個函數。在addChild(_skinImgDo);後面加入_skinImgDo.visible = false;(雖然不懂,但是這些看看也都能知道個大概)
好了。修改完畢。至於其他的修改,大家可以自己看看源檔案。反正功能老外都幫我們現實了,我們只要修修改改而已。
補充一點,如果想用,入:
找到項目bin-debug下面的flexpaper.swf。(其他的swf就是我之前沒有合并到代碼中的那些swf,如果沒有合并的需要把這些swf檔案全部一起拷貝)
放在你下載回來的例子中,替換如下:
把剛才的檔案改成這個名字就OK了。然後在運行就會發現可以了。
上面的方法似乎是把flash已經寫死了,下面的這種方法編譯出來的swf應該是可以動態載入flash的。(從網上找到的)
<?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 = true;//是否支援列印
[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", true);
_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="一個人">
<mx:Label x="59" y="37" text="{Scale}" width="88"/>
</mx:Panel-->
<fp:FlexPaperViewer id="paperViewer"
width="100%"
height="100%"
Scale="{_Scale}"
SwfFile="{_SwfFile}"
ZoomTransition="{_ZoomTransition}"
ZoomTime="{_ZoomTime}"
ZoomInterval="{_ZoomInterval}"
FitPageOnLoad="{_FitPageOnLoad}"
FitWidthOnLoad="{_FitWidthOnLoad}"
PrintEnabled="{_PrintEnabled}"
FullScreenAsMaxWindow="{_FullScreenAsMaxWindow}"
ProgressiveLoading="{_ProgressiveLoading}" />
</mx:Application>
但是按照上述方法試了下,就無法調用官方提供的API介面了。原因是上述的程式並沒有提供介面(介面在FlexPaperViewer_Base.mxml)這個檔案中
只需要加入如下的語句,就可以調用gotoPage介面了
public function gotoPage(p:Number):void{
paperViewer.gotoPage(p);
}
別忘了增加一句監聽,給js調用
ExternalInterface.addCallback("gotoPage", gotoPage);
到此OK。編譯出來的可以載入API了。
添加列印:
增加一句監聽,給js調用
ExternalInterface.addCallback("printPaper", printPaper);
public function printPaper():void{
paperViewer.printPaper();
}
修改FlexPaperViewer.mxml
click="printPaper(event)" 為click="printPaper()"
修改FlexPaperViewer_Base.mxml
public function printPaper(e:Event):void{...}為public function printPaper():void{...}