[英]flex ExternalInterface won't execute call() function
For some reason, the ExternalInterface.avaiable shows true, but it won't call alert(). 由于某些原因,ExternalInterface.avaiable显示为true,但不会调用alert()。 Can anyone shed some light to this problem?
谁能阐明这个问题?
private function checkEI():void {
eiStatus = ExternalInterface.available.toString();
ExternalInterface.call("alert", "hi");
}
My config is here: 我的配置在这里:
var params = {
menu: "false",
scale: "noScale",
allowFullscreen: "true",
allowScriptAccess: "always",
bgcolor: "",
wmode: "direct" // can cause issues with FP settings & webcam
};
Looks like it has to do with not being in a webserver and the html file just being opened directly by the browser. 看起来这与不在网络服务器中以及html文件仅由浏览器直接打开有关。 Is there any way to get it to work without a webserver?
有没有办法让它在没有网络服务器的情况下工作?
Here's my answer that I posted a while ago. 这是我前一段时间发布的答案。 Hope it helps.
希望能帮助到你。
Extract: 提取:
I figured out that for some reason ExternalInterface.call doesn't work on a file:// and needs http(s)://
我发现出于某种原因,ExternalInterface.call在file://上不起作用,并且需要http(s)://
So, anybody who is facing this problem, get your yourself a webserver(Apache) or a GAE for testing these kinds of things
因此,面对此问题的任何人,请让您自己使用Web服务器(Apache)或GAE来测试这些事情
Try to specify both id
and classid
in embed parameters. 尝试在嵌入参数中同时指定
id
和classid
。 It helped me in all the browsers (especially IE). 它在所有浏览器(特别是IE)中对我都有帮助。
Have you tried 你有没有尝试过
ExternalInterface.call("javascript:alert", "hi");
On second thought, Flash's security policy disallows the swf from calling a javascript in an html over the file protocol. 再次考虑,Flash的安全策略禁止swf通过文件协议调用html中的javascript。 You will get this error:
#2060: Security sandbox violation: ExternalInterface caller file: c:/test.swf cannot access file: c:\\testhtml.htm
您将收到以下错误:
#2060: Security sandbox violation: ExternalInterface caller file: c:/test.swf cannot access file: c:\\testhtml.htm
I believe a similar question also exists at Does ExternalInterface work on the file: protocol? 我相信, ExternalInterface是否在文件:协议上工作时也存在类似的问题?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.