我有一个我通过Eclipse启动的Flex应用程序。 现在,如果我使用以下命令打开一个新选项卡(例如在Firefox中):
var url:String = 'DeepLinkingProject.html#view=1';
var urlReq:URLRequest = new URLRequest(url);
navigateToURL(urlReq,'_blank');
我有两个相同应用程序的实例。但我不希望这样。 我希望这两个共享相同的应用程序实例,如果我在一个浏览器选项卡中更新一个组件,我希望同步其他浏览器选项卡。
这可能吗?!
测试示例:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:local="*" xmlns:test="test.*" creationComplete="init()" >
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import flash.net.navigateToURL;
import mx.events.BrowserChangeEvent;
import mx.managers.BrowserManager;
import mx.managers.IBrowserManager;
import mx.utils.URLUtil;
private var bm:IBrowserManager;
private var isParsing:Boolean;
private var title:String;
private function init():void{
bm = BrowserManager.getInstance();
bm.init("","Start");
bm.addEventListener(BrowserChangeEvent.BROWSER_URL_CHANGE, parseURL);
callLater(parseURL);
}
private function parseURL():void{
//isParsing = true;
//var o:Object = URLUtil.stringToObject(bm.fragment);
//if (o.view == undefined)
// o.view = "Home";
//bm.setTitle(title);
//isParsing = false;
}
private function updateU():void{
var fragments:String = "";
fragments = bm.fragment;
btnA.label = fragments;
/////////////////////////////////////////////////////////////////////////
// e.g. After this call, a new Browser-Tab gets opened and the
// Button Component should have the same Label content
navigateToURL(new URLRequest('DeepLinkingProject.html'));
/////////////////////////////////////////////////////////////
}
private function changeUrl():void{
bm.setFragment('view=B');
updateU();
}
]]>
</fx:Script>
<mx:VBox>
<s:Label id="header" text="Application started without Parameters"/>
<mx:HBox borderStyle="solid">
<s:Button id="btnA" click="changeUrl()"/>
</mx:HBox>
</mx:VBox>