javascript - 将数组从 Flash (AS3) 发送到 JavaScript

标签 javascript flash actionscript-3 externalinterface

是否可以使用 ExternalInterface 调用将数组从 Flash (AS3) 发送到 JavaScript?

我目前在 Flash 中的“for each”循环中多次调用一个函数,但它运行得太快,JavaScript 无法跟上。

我的想法是创建一个属性数组,将其传递给 JavaScript 函数,然后在 JavaScript 中循环遍历它。

谢谢, 乔希

最佳答案

是的,这是可能的。

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html#call()

... 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/

相关文章:

javascript - Firefox 的 Flash 外部接口(interface)问题

flash - A.R Drone 2.0 视频流延迟

actionscript-3 - 滚动到 Flex 4 Spark List 组件中的选定项

image - 从图像创建 .flv

javascript - 从重定向获取链接

javascript - 如何使用 Vue-Router 在 Vue 中设置数组 URL 查询参数

javascript - 在 Javascript 中从 HTML 表单数组获取值

html - 使用 base64 编码将 .swf 嵌入到 html 中

actionscript-3 - Adobe Flash中的背景音乐不断重复吗?

Javascript 将远程 XML 文件读入数组