views:

83

answers:

1

Hello,

I am using the ExternalInterface to communicate between Flash and JavaScript using callbacks and the call method. I would like to throw an exception in ActionScript 3.0 and catch it in JavaScript and I was please wondering if there was anyway to do that?

Thank you very much, Rudy

A: 

Should be something like:

try {
     // statements
} catch (error:Error) {
     ExternalInterface.call(functionsName, error.message);
}

Where functionsName is the function that will get the error as a parameter.

ozke
Thank you, that's currently what I am doing but I was wondering if there was any way to actually catch the exception in JavaScript rather than rely on the ExternalInterface. I guess there is not. Thanks for your help!
Rudy
Well, actionscript works inside a swf file via Flash Player. JS works in a completely different world outside of the swf. Think of the SWF like a Virtual Machine (it actually is more or less).So basically, you need to handle the error in AS first, other ways there is no way to let JS know.
ozke
Okay it does makes sense. Thanks a lot!
Rudy