R – the best way to handle refreshing a localConnection between AS3 and AS2 swfs using SWFBridge? (load, unload, load again)

actionscriptactionscript-2actionscript-3flashlocalconnection

I have an AS2 swf that is hosted by an AS3 swf and they connect using SWFBridge. During the course of things i need to unload the AS2 swf and reload it. Therefore I assume I need to re-establish the SWFBridge connection. But when I try to reopen the connection it doesnt appear to work. Heres what I have –

AS3 Code:

var myBridge:SWFBridgeAS3;
function setUpBridge() :void {
   myBridge = new SWFBridgeAS3("connectionID", this);
   myBridge.addEventListener(Event.CONNECT, handleConnect);
}
setUpBridge(); // the first time
loadAS2SWF(); // loads the As2 swf using Loader class

… sometime later

loader.unload(); // unload the AS2 swf
myBridge.close();
setUpBridge();
loadAS2SWF();

Can anyone see what I'm doing wrong? Everything works fine for the first load of the AS2 swf but the connection is not being established in subsequent loads….

… incidentally – it would appear that when reconnecting, the communication works ok from the host to the client but no calls to functions from clien to host swf are received?? confusing!

Thanks

————————————- UPDATE ——————————————-

I found that when I had 2 browser windows open SWFBridge would not work. It seems there is an issue with connections using the same ID. For a discussion of this and some workarounds search for 'multiple-connection issue' on Grant Skinner's blog

Hope this helps.

Best Answer

uhm, looking at the implementation, it looks as it would work perfectly, if you create only one bridge and leave it connected, since it will be the host, normally, as the as2 movie is loaded afterward ...

don't have a flex sdk here ... could you just check?

greetz

back2dos

Related Topic