views:

411

answers:

2

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.

+1  A: 

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?

back2dos
A: 

Did you ever find an answer to this? I am having the same issue.

jon
No the reason I wanted to reload the swf was to refresh the data that the swf was using, so instead of reloading the swf (a pretty ugly solution anyway) I wrote a function to reload the data and refresh the display which takes less time and is ultimately a better solution. Hope you can do something similar, does this help? I've added some extra information the question about why reloading the swf didnt work.
undefined