Method _ JavaScript For cross-origin Flash calling in javascript

Source: Internet
Author: User
This article mainly introduces the method of cross-origin Flash calling in JavaScript. You only need to add one sentence to Flash. If you need it, you can refer to the function of sending a text message on the page, originally, we wanted to use bgsound under Audio + IE in HTML5 to implement it. However, we found that the decoding types of Audio in each browser were not the same, and it suddenly felt like a crash. 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 needAdd allowscriptaccess = always to the tag.

Second, if you want JavaScript on your page to Access Flash, you need to add the following content in your Flash script:

The 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.