当前位置: 动力学知识库 > 问答 > 编程问答 >

How to return reference to a function in ActionScript to JavaScript?

问题描述:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: