Techblog

Tech Blog

Our latest geek adventures!

13 March Error calling method on NPObject!

UPDATE:
To fix the issue I discussed some days ago(see below) use:
System.security.allowDomain(”http://ip-adress”);
ip-adress is the IP you are developing on! This will fix the security issues!

While trying to let Actionscript talk to Javascript using the External Interface API of Actionscript I bounced upon a problem when Actionscript tried to invoke this Javascript function. In Firefox 2.0.0.2 an alert message shouted to me: “Error calling method on NPObject! [plugin exception: Error in Actionscript. Use a try/catch block to find error.].”.

My precise environment was, the html running on the localhost (Rails application) and the swf from an other domain and this seemed to be the problem. When I deployed the Rails application to this server, there was no problem at all invoking these functions. It looks like a bug in the flash player, cause I tried all the security settings possible in flash, the famous crossdomain.xml, adding all locations to the flash settings but no result. Somehow the SWF from that other domain had some troubles talking to the local javascript.

My way to solve this issue was to load the SWF also from the localhost. Everything works perfectly and I can continue testing.

Tags: , ,

7 Responses to “Error calling method on NPObject!”

  1. Cc Says:

    Sweet thanks, didn’t think of that

  2. mcbk Says:

    Joebert from ozzu.com suggests changing your javascript function that detects the Flash Player type to:

    function getSWF(movieName) {
    if (navigator.appName.indexOf(”Microsoft”) != -1) {
    return window[movieName];
    }
    else {
    if(document[movieName].length != undefined){
    return document[movieName][1];
    }
    return document[movieName];
    }
    }

    http://www.ozzu.com/ftopic74795.html

  3. Jaap Says:

    mcbk, thanks for your reply, this can help for some people. but our problem was about the different domains the swf and javascript were on. The system.allowdomain(’*') will still solve those problems as I think.

  4. Neculai Gabriel Says:

    Hi,

    Your solution makes sense. But there’s still a problem. Of using 3th part SWF that you cannot alter. It’s kind of sad to know that the only solution is to change the SWF. I know that you can decompile it. But I’m not a very good Flash developer and I really had problems trying to decompile, modify and recompile a particular SWF. I’ll try to contact the developer to help me with that.

    Thank you.

  5. Darren Says:

    Hi, Jaap

    I’ve also met this problem only in ff2.0.2.
    But it is more strange like this scenario:
    when AS call JS function, i.e. ExternalInterface.call(foo…);
    That is ok.
    However when JS call AS function, this issue will occur.
    Your solution seems not to help me. Waiting for your update, thanks!

  6. Darren Says:

    sorry, it’s in firefox 2.0.0.20

  7. Neculai Gabriel Says:

    Hi,

    I have a very painful cross domain scripting problem. I’ve tested every crazy thing to fix it and nothing really works. Please see http://flashpanoramas.com/forum/showthread.php?t=2001 where I’ve described my issue. Any help or idea would be highly appreciated.

    Best regards,
    Gabi

Leave a Reply