`
cuitengfei
  • 浏览: 7795 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

在线文档阅读器FLEX源码

阅读更多

用flexPaper源码编译出swc文件

然后新建flex项目

导入该SWC

编译以下代码:

 

?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();"  x="0" y="0"   
	
	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.5;   
			
			[Bindable]   
			public var _ZoomInterval:Number = 0.1;   
			
			[Bindable]   
			public var _FitPageOnLoad:Boolean = false;//加载后适合高度   
			
			[Bindable]   
			public var _FitWidthOnLoad:Boolean = true;//加载后适合宽度   
			
			[Bindable]   
			public var _PrintEnabled:Boolean = true;//是否支持打印   
			
			[Bindable]   
			public var _FullScreenAsMaxWindow:Boolean = true;//是否支付全屏   
			
			[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.5);   
				_ZoomInterval = getNumber(params, "ZoomInterval", 0.1);   
				_FitPageOnLoad = getBoolean(params, "FitPageOnLoad", false);   
				_FitWidthOnLoad = getBoolean(params, "FitWidthOnLoad", true);   
				_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}"  x="0" y="0" paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0"/   
/mx:Application
 

 

分享到:
评论
2 楼 csy2011 2012-08-15  
楼主,有个问题想请教你,我按照mark的教程修改源码使FlexPaper能够读中文的swf文件了,但是又出现了不能使用原来的异步加载功能了,该怎么修改源码呢?急需,请指教。
1 楼 EyejavaLi 2011-03-20  
能直接支持pdf文件的吗?

像flex的文件浏览是不是只支持swf格式的

相关推荐

Global site tag (gtag.js) - Google Analytics