I am struggling with flash and firefox (latest, 35.0.1) and can't find any solution. I want to call an ActionScript function with javascript, using ExternalInterface. So I wrote this simple javascript function (App is just an object to wrap my functions):
App.swfCall = function(callbackName, params) {
var callback = $('#swf object, #swf embed')[0][callbackName];
if(typeof(callback) === "function") {
callback.apply(null, params); // executed but throws NPObject error...
}
}
And Firefox throws an error:
Bad NPObject as private data!
The only help I found about this error is not relevant with my issue, as:
- Everything is ready at this moment; actually the action is first initiated by a user action on the swf itself
- There is no cross-domain issues (everything on the same domain)
Actually, if I do not use the Function javascript object (either with call() or apply()), everything works fine. So this is working:
App.swfCall = function(callbackName, data) {
var swf = $('#swf object, #swf embed')[0];
if(typeof(swf[callbackName]) === "function") {
swf[callbackName](data);
}
};
Anyway there are many problems with this:
- I can just pass a single argument to the function
- ...And I have to check if the parameter is the "data" parameter is not null
- I cannot pass null parameters beacause of that (not the biggest issue)
So all I need is to be able to pass parameters to the swf (0, one or more!) And I'd really like to understand what is happening, too.
I said there is no cross-domain issues, actually it is an iframe within facebook. But obviously everything is inside it and on the same domain, so it shouldn't be a problem.. should it?
Thank you!