<?xml version="1.0" encoding="utf-8"?> <gui:RCPModule xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:gui="cn.smartinvoke.gui.*" xmlns:rcp="cn.smartinvoke.rcp.*" layout="vertical" horizontalAlign="center" verticalAlign="middle" width="712" height="322" creationComplete="openView()"> <mx:Script> <![CDATA[ import cn.smartinvoke.smartrcp.gui.FlashViewer; import cn.smartinvoke.smartrcp.gui.control.ViewManager; import mx.collections.ArrayCollection; import mx.controls.Alert; var path:String="*sourceBrowser"; //"cn.smartinvoke.smartrcp.WebBrowser";//"views/ContextMenu_T.swf"; function init():void{ } private var openedView:FlashViewer; function openView():void{ smartrcpDemo.Instance.setInfo("当前模块会自动打开一空白的浏览器, 此模块可以对该浏览器窗口进行最大化最小化,调用其" + "setHtml方法设置html内容,调用execute方法执行一段js代码"); this.openedView=ViewManager.Instance.findFlashViewers(path)[0] as FlashViewer; //openedView.invoke("openUrl",[]); } function closeView():void{ ViewManager.Instance.closeViewPart(this.getView()); } function getView():String{ var str:String=""; var viewIds:ArrayCollection=ViewManager.Instance.findAppIds(this.path); if(viewIds!=null && viewIds.length>0){ return viewIds[0] as String; } return null; } function showView():void{ var appId:String=this.getView(); ViewManager.Instance.showViewPart(appId); } function maxView():void{ var appId:String=this.getView(); ViewManager.Instance.setState(appId,ViewManager.STATE_MAXIMIZED); } function minView():void{ var appId:String=this.getView(); ViewManager.Instance.setState(appId,ViewManager.STATE_MINIMIZED); } function restoreView():void{ var appId:String=this.getView(); ViewManager.Instance.setState(appId,ViewManager.STATE_RESTORED); } ]]> </mx:Script> <mx:Panel title="rcp ViewPart管理器,包括ViewPart的打开,关闭,最大化,最小化等" cornerRadius="0" horizontalAlign="center" verticalAlign="middle" styleName="opaquePanel" width="712" height="100%" layout="absolute"> <!--<mx:Button label="打开视图" click="openView()" x="33" y="44"/> --> <mx:Button label="关闭视图" click="closeView()" y="202" x="33"/> <mx:Button label="最大化视图" click="maxView()" y="74" x="33"/> <mx:Button label="最小化视图" click="minView()" y="138" x="33"/> <mx:Button label="恢复视图" click="restoreView()" y="106" x="33"/> <mx:Button label="显示视图" click="showView()" x="33" y="170"/> <mx:Label x="33" y="10" text="基本操作" width="101"/> <mx:Label x="201" y="10" text="方法调用" width="101"/> <mx:TextArea x="201" y="54" height="128" id="textAreaInput"/> <mx:TextArea x="383" y="54" height="128" width="223" id="textJs"/> <mx:Button x="227" y="202" label="显示输入内容" click="showHTML()"/> <mx:Button x="438" y="202" label="执行输入脚本" click="executeJS()"/> </mx:Panel> <mx:Script> <![CDATA[ function showHTML():void{ if(this.openedView!=null){ this.openedView.invoke("setHtml",[this.textAreaInput.text]); } } function executeJS():void{ if(this.openedView!=null){ var ret:Boolean=this.openedView.invoke('execute',[this.textJs.text]) as Boolean; if(ret){ Alert.show("执行成功"); }else{ Alert.show("执行失败"); } } } ]]> </mx:Script> </gui:RCPModule>