I have one Flex application which I launched via Eclipse. Now if I open a new tab (e.g in Firefox) with these commands:
var url:String = 'DeepLinkingProject.html#view=1';
var urlReq:URLRequest = new URLRequest(url);
navigateToURL(urlReq,'_blank');
I have two instances of the same application. But I do not want that. I want that these two share the same application instance and if I update one component in one browser-tab I want the other browser-tab to be synchronized.
Is this possible?!
test example:
<?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>