flexExternalInterface不会执行call()函数

发布于 2024-12-03 04:08:36 字数 556 浏览 0 评论 0原文

由于某种原因,ExternalInterface.avaiable显示为true,但它不会调用alert()。任何人都可以阐明这个问题吗?

private function checkEI():void {
     eiStatus = ExternalInterface.available.toString();
     ExternalInterface.call("alert", "hi");
}

我的配置在这里:

var params = {
    menu: "false",
    scale: "noScale",
    allowFullscreen: "true",
    allowScriptAccess: "always",
    bgcolor: "",
    wmode: "direct" // can cause issues with FP settings & webcam
};

看起来它与不在网络服务器中并且 html 文件只是由浏览器直接打开有关。有没有办法让它在没有网络服务器的情况下工作?

For some reason, the ExternalInterface.avaiable shows true, but it won't call 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. Is there any way to get it to work without a webserver?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

原来分手还会想你 2024-12-10 04:08:36

尝试在嵌入参数中指定 idclassid。它在所有浏览器(尤其是 IE)中对我都有帮助。

Try to specify both id and classid in embed parameters. It helped me in all the browsers (especially IE).

叹梦 2024-12-10 04:08:36

这是我不久前发布的答案。希望有帮助。

摘录:

我发现由于某种原因ExternalInterface.call不起作用
在 file:// 上并且需要 http(s)://

所以,任何面临这个问题的人,请给自己一个解决方案
用于测试此类事物的网络服务器(Apache)或 GAE

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)://

So, anybody who is facing this problem, get your yourself a
webserver(Apache) or a GAE for testing these kinds of things

紫罗兰の梦幻 2024-12-10 04:08:36

你有没有尝试

ExternalInterface.call("javascript:alert", "hi");

过再三考虑,
Flash 的安全策略不允许 swf 通过文件协议调用 html 中的 javascript。你会得到这个错误:
#2060: 安全沙箱违规:ExternalInterface 调用者文件:c:/test.swf 无法访问文件:c:\testhtml.htm

我相信 ExternalInterface 是否适用于文件:协议?

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. You will get this error:
#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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文