How do I call a function in swf AS2 hosted in swf AS3 and return the array back to AS3 swf? (using SwfBridge)

I have a Flash CS4 AS3 swf (host) that downloads the swf (client) Flash 8 AS2 using gSkinner swfBridge.

This works great and the host can call functions in the client without issue. However, I want to be able to call a function in the client and return that function to the host of that function.

This is the code that I thought would work -

Host Code (AS3) -

var hostArray:Array = new Array();
hostArray = mySwfBridge.send("getArray");

      

Client (AS2) code

var theArray = new Array("item1, item2, item3);
function getArray() :Array {
    return theArray;
}

      

any ideas?

0


a source to share


1 answer


The problem you are facing is that LocalConnection

(is used SwfBridge

) calls asynchronously. In other words, executing the caller's script will not stop its execution to wait for the result back from the called function.



If you need to get the value from the other side LocalConnection

, you need to configure it to work in bi-directional mode. those. your client script should send its result back to the callback method for the host object via LocalConnection

( SwfBridge

in this case) using instead return

.

+2


a source







All Articles