是否可以使用 ExternalInterface 调用将数组从 Flash (AS3) 发送到 JavaScript?
我目前在 Flash 中的“for each”循环中多次调用一个函数,但它运行得太快,JavaScript 无法跟上。
我的想法是创建一个属性数组,将其传递给 JavaScript 函数,然后在 JavaScript 中循环遍历它。
谢谢, 乔希
最佳答案
是的,这是可能的。
... arguments — The arguments to pass to the function in the container. You can specify zero or more parameters, separating them with commas. They can be of any ActionScript data type. When the call is to a JavaScript function, the ActionScript types are automatically converted into JavaScript types; when the call is to some other ActiveX container, the parameters are encoded in the request message.
快速测试:
AS 代码:
if(ExternalInterface.available) {
ExternalInterface.call("jsTest", [0,1,"two",{a:1,b:2}]);
}
JS代码:
function jsTest(arg) {
alert(arg);
}
关于javascript - 将数组从 Flash (AS3) 发送到 JavaScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1058589/