我试图从JavaScript调用一个Actionscript函数,但我在Internet Explorer中遇到问题.我在mootools 1.2.1中使用Swiff.remote来调用actionscript函数,即:
Swiff.remote(playSwf.toElement(), 'sendResult', result, plays, name);
这一切在FireFox,Safari和Opera中运行良好,但我在Internet Explorer 6和7中遇到"未指定"的错误.我尝试过使用沼泽标准:
window['flash'].sendResult(result, plays, name);
无济于事.
谢谢你的帮助.标记
我不熟悉Swiff插件,但你不需要插件来从Javascript调用flash函数.在本地进行它更容易.
来自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); }