AS2 ExternalInterface: Error: An invalid exception was thrown

539 views Asked by At

I'm currently trying to do something with Flash and javascript using ExternalInterface.

As soon as the javascript function is executed, and with a callback should send something to Flash, the following error appears in my browser console:

Error: An invalid exception was thrown.

Here is the code:

//JavaScript:
var obj = swfobject.getObjectById("flash-wrapper");
obj.sendLogin(this.getCookie("username"), this.getCookie("password"));

//ActionScript 2:
ExternalInterface.addCallback('sendLogin', __reg2, __reg2.sendLogin);
ExternalInterface.call('init');

I would be happy about help. I try to solve this problem in the meantime for 2 hours.

1

There are 1 answers

0
Attos On

I have a same problem, but in as3. My trouble was that callback function in action script was private . I set it in public and exception disapper.

And check in AS:

  1. Security.allowDomain("*");
  2. ExternalInterface.available

And in js check, that you get right flash object: for example, in chrome get object after

<!--[if !IE]>-->