FlexPaper使用小记

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"  
  3.                 xmlns:fp="com.devaldi.controls.flexpaper.*"  
  4.                 layout="absolute" width="100%" height="100%"   
  5.                 applicationComplete="initApp();">  
  6.       
  7.     <mx:Script>  
  8.         <![CDATA[  
  9.             import mx.controls.Alert;  
  10.               
  11.             public var _aid = 0;//文档ID  
  12.               
  13.             [Bindable]  
  14.             public var _Scale:Number = 1;//缩放比例  
  15.               
  16.             [Bindable]  
  17.             public var _SwfFile:String = "";//SWF文件路径  
  18.               
  19.             [Bindable]  
  20.             public var _ZoomTransition:String = "easeOut";  
  21.               
  22.             [Bindable]  
  23.             public var _ZoomTime:Number = 0.6;  
  24.               
  25.             [Bindable]  
  26.             public var _ZoomInterval:Number = 0.1;  
  27.               
  28.             [Bindable]  
  29.             public var _FitPageOnLoad:Boolean = false;//加载后适合高度  
  30.               
  31.             [Bindable]  
  32.             public var _FitWidthOnLoad:Boolean = false;//加载后适合宽度  
  33.               
  34.             [Bindable]  
  35.             public var _PrintEnabled:Boolean = true;//是否支持打印  
  36.               
  37.             [Bindable]  
  38.             public var _FullScreenAsMaxWindow:Boolean = false;//是否支付全屏  
  39.               
  40.             [Bindable]  
  41.             public var _ProgressiveLoading:Boolean = false;//是否延迟加载  
  42.               
  43.             [Bindable]  
  44.             public var _localeChain:String = "zh_CN";//语言  
  45.               
  46.             private var isFocus:Boolean = false;  
  47.               
  48.             //初始化参数  
  49.             private function initApp():void{  
  50.                 var params:Object = Application.application.parameters;  
  51.                 _Scale = getNumber(params, "Scale"1);  
  52.                 _SwfFile = getString(params, "SwfFile""Paper.swf");  
  53.                 _ZoomTransition = getString(params, "ZoomTransition""easeOut");  
  54.                 _ZoomTime = getNumber(params, "ZoomTime"0.6);  
  55.                 _ZoomInterval = getNumber(params, "ZoomInterval"0.1);  
  56.                 _FitPageOnLoad = getBoolean(params, "FitPageOnLoad"false);  
  57.                 _FitWidthOnLoad = getBoolean(params, "FitWidthOnLoad"false);  
  58.                 _PrintEnabled = getBoolean(params, "PrintEnabled"true);  
  59.                 _FullScreenAsMaxWindow = getBoolean(params, "FullScreenAsMaxWindow"false);  
  60.                 _ProgressiveLoading = getBoolean(params, "ProgressiveLoading"true);  
  61.                 _localeChain = params["localeChain"];  
  62.                   
  63.                 //注册事件监听  
  64.                 this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);  
  65.                 this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);  
  66.                   
  67.                 //开放给外部(javascript)调用  
  68.                 ExternalInterface.addCallback("hasFocus", hasFocus);  
  69.                 //ExternalInterface.addCallback("focus", focus);  
  70.                 ExternalInterface.addCallback("setViewerFocus", setViewerFocus);      
  71.             }  
  72.               
  73.               
  74.               
  75.             private function onMouseOver(event:MouseEvent):void{  
  76.                 this.isFocus = true;  
  77.             }  
  78.               
  79.             private function onMouseOut(event:MouseEvent):void{  
  80.                 this.isFocus = false;  
  81.             }  
  82.               
  83.             public function hasFocus():Boolean{  
  84.                 //Alert.show("hasFocus");  
  85.                 return isFocus;  
  86.             }  
  87.               
  88.             public function setViewerFocus(isFocus:Boolean):void{  
  89.                 //Alert.show("setViewerFocus");  
  90.                 this.paperViewer.setViewerFocus();  
  91.             }  
  92.               
  93.             /** 
  94.              *  
  95.              * 获取String类型参数 
  96.              * 如果没有,则返回默认值 
  97.              **/  
  98.             private function getString(params:Object, name:String, def:String):String{  
  99.                 if(params[name] != null){  
  100.                     return params[name];  
  101.                 }  
  102.                 return def;  
  103.             }  
  104.               
  105.             private function getNumber(params:Object, name:String, def:Number):Number{  
  106.                 if(params[name] != null){  
  107.                     return params[name];  
  108.                 }  
  109.                 return def;  
  110.             }  
  111.               
  112.             private function getBoolean(params:Object, name:String, def:Boolean):Boolean{  
  113.                 //Alert.show("比较:"+name);  
  114.                 if(params[name] != null){  
  115.                     return params[name] == "true";  
  116.                 }  
  117.                 return def;  
  118.             }  
  119.         ]]>  
  120.     </mx:Script>  
  121.     <!--mx:Panel x="165" y="76" width="250" height="200" layout="absolute" title="一个人">  
  122.     <mx:Label x="59" y="37" text="{Scale}" width="88"/>  
  123.     </mx:Panel-->  
  124.       
  125.     <fp:FlexPaperViewer id="paperViewer"  
  126.         width="100%"   
  127.         height="100%"   
  128.         Scale="{_Scale}"   
  129.         SwfFile="{_SwfFile}"   
  130.         ZoomTransition="{_ZoomTransition}"   
  131.         ZoomTime="{_ZoomTime}"   
  132.         ZoomInterval="{_ZoomInterval}"  
  133.         FitPageOnLoad="{_FitPageOnLoad}"  
  134.         FitWidthOnLoad="{_FitWidthOnLoad}"  
  135.         PrintEnabled="{_PrintEnabled}"  
  136.         FullScreenAsMaxWindow="{_FullScreenAsMaxWindow}"  
  137.         ProgressiveLoading="{_ProgressiveLoading}" />  
  138. </mx:Application>  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

分布式编程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值