Archive

Error calling method on NPObject! Flash js error

This is by far one of the weirdest bugs I have seen. I appears that flash has some kind of security feature for detecting what is the origin of object variables that are being passed to the JavaScript API. If such variable comes from untrusted source, in my case this was same domain iframe, it troughs this error: Error calling method on NPObject! Not being a flash guy, this kind of made me hate adobe, for not having a better error message, and have me waist few hours trying to figuring out what's gong on.... oh and since there is such a simple hack for it, this "security" feature is a joke anyway!!

Solution: I tried just to sign the passed variable to a local variable but that did not work, so what I had to do was loop through each member of the array, and re-assign it one by one, so this is the work around hack.

Here is a nice utility function using does the job for you:

        var hideOrigin = function(list){
        
            var list2 = [];

            $.each(list, function(i, d) {
                list2[i] = d;
            });
            
            return list2;
        }

So when you are passing a "dirty" object to the flash movie, you can just do something like this:

thisMovie("swfId").external(hideOrigin(suspiciousObject));

Comments: