3
votes

First version:

ExternalInterface.call("$(document).trigger", "opened_file_chooser");

Second version:

ExternalInterface.call("$(document).trigger('opened_file_chooser')");

If I use the first version, it's much, much slower than the second. Also, the browser blocks, and after a few seconds Firefox shows me the dialog with "A script is not responding ... " and it offers me the possibility of stopping it. If I use the 2nd version, the call to Javascript is instantaneous. Is there a way I could make the first one work as well as the second? I think it's much cleaner ( from a code point of view ).

1
Just a guess, but since ExternalInterface calls are synchronous it's probably waiting for a response from the file chooser before returning. The second might be working because it's just returning the object that is the whole function? - BadFeelingAboutThis
Do you notice the same slowness if you, say, execute those statements in a browser's javascript console? I'm not JS expert, so the difference between those two statements is lost on me. But it would seem to me that this problem should also happen when not using ExternalInterface and just executing those statements directly. - Sunil D.
@LondonDrugs_MediaServices shouldn't the 2 ways of calling ExternalInterface produce the same result? - Geo
@SunilD. , how can I execute the ExternalInterface.call from the browser's console? It's a flash method call. - Geo
if you use a middle man function, does it change anything? eg. function openFileChooser(){ $(document).trigger('opened_file_chooser');} - and calling that from flash? It's generally cleaner to use a single function as an ExternalInterface call, because then if you need to update the javascript side you don't have to recompile the flash side. - BadFeelingAboutThis

1 Answers

0
votes

Try setting a timeout which will let ExternalInterface "return" to Flash which should help with the blocking:

ExternalInterface.call("setTimeout","$(document).trigger('opened_file_chooser')","100");