问题描述:

If I want to return a reference to an arbitrary function in ActionScript to JavaScript, what should I have to do?

For example, I can make an object with some method functions.

function maker()

{

const o = {};

o.a = function() {};

o.b = function() {};

return o;

}

I can do same thing in both of JavaScript and ActionScript. But If I send the object made in ActionScript to JavaScript via ExternalInterface, it will be just an empty object. It's members disappears. How can I return those reference to functions?

网友答案:

Unfortunately, you can't.

The best thing to do is to store your function in a dictionary and pass the key, as a string, out through the external interface. Your JavaScript code can then invoke a dispatcher function with the key, to cause your AS code to call the right function.

相关阅读:
Top