"Error calling method on NPObject!" for flex deep linking
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 param开发者_运维百科eter 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?
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 ] )
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.
精彩评论