JavaScript calls Flash methods across domains

  • 2020-03-30 03:41:09
  • OfStack

To do a page short message prompt sound function, originally wanted to use HTML5 Audio+IE under the bgsound to achieve, but found that each browser to Audio decoding type is not the same, immediately have a sense of collapse. There's no way to play it safe with Flash.

I'm sure that JavaScript interacts with Flash in a way that you've probably heard about. Actually, this is the first time I've done this. I won't talk about the specific method, a lot of data.

At the beginning of the function is done, implementation and no problem. But at the end of the day, when the problem arose when the SWF file was placed on the resource service and invoked, I thought it must be another painful cross-domain problem. Later on the Internet through a long time finally solved the problem.

First, for your Flash to be able to access the page, you need to Embed> Tag with allowscriptaccess=always.

Secondly, to make Flash accessible to JavaScript on your page, you need to add the following to your Flash script:


import flash.system.Security;
Security.allowDomain('www.jb51.net');


Related articles: