I have a flash movie and I am using ExternalInterface.call function to call a javascript function from within the movie. The problem is that whenever the javascript function gets executed in Mozilla Firefox, the browser becomes non-responsive. I have uploaded the file here: http://www.aakashb.0fees.net/carbon6.html This is a map of India and a javascript function in called when you click on the top-most state (that's the state of Jammu and Kashmir ). Open it in a new window...it might make your browser non-r开发者_StackOverflowesponsive too.
there're two mistakes in your approach:
you can call javascript function directly from ExternalInterface.call.
so there's no need to call eval in your javascript code.
ExternalInterface.call('alert', "alert from swf!");
alert will block the execution of javascript codes
try this code:
alert(1);
console.log(1); // execution of this line is blocked by 'alert'
alert(2);
console.log(2); // execution of this line is blocked by 'alert'
so, if you eval 'alert', the execution of code is blocked and your browser may be non-responsive.
this will be avoided very easily. change your javascript function 'evaluate' as follows
function evaluate(code) {
setTimeout(function () {
eval(code);
}, 0);
}
settimeout will simply postpone the execution of 'alert' and return the callback from actionscript as soon as possible.
精彩评论