Javascript来闪通信 [英] Javascript to flash communication
问题描述
我想从JavaScript中调用一个ActionScript函数,但我有在Internet Explorer中的问题。 我使用Swiff.remote在MooTools的1.2.1调用ActionScript函数,即:
I am trying to call a Actionscript function from javascript but I am having problems in Internet Explorer. I am using Swiff.remote in mootools 1.2.1 to call the actionscript function ie:
Swiff.remote(playSwf.toElement(), 'sendResult', result, plays, name);
这一切工作正常在Firefox,Safari和Opera,但我发现了一个未指定错误在Internet Explorer 6和7。 我已经使用了沼泽标准的尝试:
This all works fine in FireFox, Safari and Opera but I'm getting an "unspecified" error in Internet Explorer 6 and 7. I have tried using the bog standard:
window['flash'].sendResult(result, plays, name);
要无果。
感谢您的帮助。 马克
推荐答案
我不熟悉的Swiff插件,但是你并不需要一个插件来从Javascript调用闪光功能。它更容易本地做。
I'm not familiar with the Swiff plugin, but you don't need a plugin to call flash functions from Javascript. It's even easier to do it natively.
从AS:
//1. calling javascript function from Flash.
ExternalInterface.call("sendData",tempStr);
// argument 1: javascript function, argument 2: data/variables to pass out.
//2. calling javascript function from Flash with recursion.
var returnValue:String = ExternalInterface.call("sendReturn",tempStr).toString();
//3. setting up a callback function for javascript
ExternalInterface.addCallback("callFlash",flashResponse);
// argument 1: function name called by javascript, argument 2: function on the Flash side.
// AS2 version looks like this : ExternalInterface.addCallback("callFlash",null,flashResponse);
从JS:
//1. javascript function as called from Flash.
function sendData(val){
alert(val);
document.flashForm.flashOutput.value = val;
}
//2. javascript function with recursion.
function sendReturn(val){
var tempData = "Hello from JS";
return tempData + ' :return';
}
//3. calling Flash function with javascript.
function sendToFlash(val){
window['flash'].callFlash(val);
}
这篇关于Javascript来闪通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!