“调用 NPObject 上的方法时出错!”用于 Flex 深度链接

发布于 2024-10-31 13:15:06 字数 1584 浏览 1 评论 0原文

我有一个 Flex 应用程序托管在域 A 上,并通过域 B 上的网页提供服务。我启用了跨域脚本;在域 B 的网页中,我有该行,

params.allowscriptaccess = "always";

并且在我的应用程序代码中

flash.system.Security.allowDomain("*");

,并且更好的是,

flash.system.Security.allowDomain("keonehon.com"); // domain A

ExternalInterface 调用似乎有效;启动时,应用程序调用 JavaScript 函数,网页回调函数以传递参数。

if (ExternalInterface.available){
                ExternalInterface.call("SWFLoadComplete");
                //lblMessage.text = "Data Sent!";
            }

function SWFLoadComplete(){
            callNewCarWithUser();
        }

        function callNewCarWithUser()
        {
          var user_id = document.getElementById('txtUserId').value;
          var room_id = document.getElementById('txtRoomId').value;
          getTheFlexApp().newCarWithUser(user_id, room_id);
        }

这可以正常工作。所以,是的。看起来工作正常,不是吗?

但是,深层链接不起作用,因为在 URL 中设置 #state=____ flex 参数(通过输入内容或使用后退按钮向后导航)会导致抛出 JavaScript 错误在 history.js 的第 435 行,又名

getPlayer().browserURLChange(flexAppUrl); 

似乎存在某种跨域安全问题,即使我放入了行 flash.system.Security.allowDomain("* ”);。通过比较具有相同 html 和 swf 文件的两个页面,您可以看到同域与跨域时有不同的行为,一种情况是跨域,另一种情况是相同域:

cross-domain: http://keonehon.com/gongos/dreamcar.html。 相同域: http://rails.mit.edu/gongos/dreamcar.html

到底是怎么回事?

I have a flex app hosted on domain A and served through a webpage at domain B. I have enabled cross-domain scripting; in the webpage at domain B, I have the line

params.allowscriptaccess = "always";

and in the application code I have

flash.system.Security.allowDomain("*");

and for good measure,

flash.system.Security.allowDomain("keonehon.com"); // domain A

ExternalInterface calls seem to work; on startup the app calls a javascript function and the webpage calls a function back to pass a parameter in.

if (ExternalInterface.available){
                ExternalInterface.call("SWFLoadComplete");
                //lblMessage.text = "Data Sent!";
            }

function SWFLoadComplete(){
            callNewCarWithUser();
        }

        function callNewCarWithUser()
        {
          var user_id = document.getElementById('txtUserId').value;
          var room_id = document.getElementById('txtRoomId').value;
          getTheFlexApp().newCarWithUser(user_id, room_id);
        }

And this works correctly. So, yeah. Seems to be working fine, no?

HOWEVER, deep linking is not working, as setting the #state=____ flex parameter in the URL (either by typing something in, or by navigating backward using the back button) causes a javascript error to be thrown at line 435 of history.js, a.k.a.

getPlayer().browserURLChange(flexAppUrl); 

It seems like there is some sort of cross-domain security problem, even though I put in the line flash.system.Security.allowDomain("*");. You can see that there are different behaviors when same-domain vs. cross-comain by comparing two pages with identical html and swf files, just cross-domain in one case and same-domain in the other:

cross-domain: http://keonehon.com/gongos/dreamcar.html.
same-domain: http://rails.mit.edu/gongos/dreamcar.html

What the heck is going on?

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

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

发布评论

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

评论(2

落花浅忆 2024-11-07 13:15:06

我不确定这是否相关,但我经常在 ExtJS 中遇到此错误,并且问题实际上最终是一个简单的语法错误(缺少括号 ] )

I'm not sure if this is related at all, but I use to get this error all the time with ExtJS and the problem actually ended up being a simple syntax error, (missing bracket ] )

冰之心 2024-11-07 13:15:06

您是否尝试过allowScriptAccess? (如果我没记错的话,这可能区分大小写)

如果这不起作用,查看更多代码或示例页面会有所帮助。

Have you tried allowScriptAccess instead? (this might be case-sensitive if I remember correctly)

If that didn't work, it'd help to see more code or a sample page.

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