Cross-origin calling of Flash in JavaScript: javascriptflash
To implement the prompt sound function of a short message on a page, we wanted to use bgsound under Audio + IE in HTML5. However, we found that the decoding types of Audio in each browser were different, suddenly there is a feeling of collapse. There is no way to use Flash.
I believe that JavaScript and Flash will be used or heard. In fact, this is also the first time I have done this thing. The specific method will not be mentioned. There is a lot of information.
At the beginning, the functions were almost done, and the implementation was correct. However, at the end of the process, when the swf file is put on the Resource Service and then called again, I think it must be a cross-domain problem (CrossDomain ). After turning over the Internet for half a day, I finally fixed the problem.
First, you need to add allowscriptaccess = always in the <embed> label to allow your Flash to access the page.
Second, if you want JavaScript on your page to Access Flash, you need to add the following content in your Flash script:
Copy codeThe Code is as follows:
Import flash. system. Security;
Security. allowDomain ('www .jb51.net ');
Here, www.jb51.net needs to be replaced with the domain of your own page. If you are not very clear, you can use alert (document. domain) to view it. If you need multiple domains to access the Flash, you can add multiple allowDomain records.
Javascript cross-origin calling of js files
The problem now is how to call the javascript method in Top in Left, or what method can be used. The precondition is that these files cannot be cross-origin, that is, they must be under a domain name, otherwise, JS
How can I call a method in falsh by using javascript?
In 3.0, ExternalInterface. addCallback (external access name string, internal function) is called)
Then get the flash reference in js and call the external access name.