flash Cross-domain problem believe that not everyone can encounter, if you publish locally, or say directly ctrl+enter in Flashide Preview, will not encounter cross-domain problem, of course, cross-domain have a prerequisite,
That is, Flash is not completely independent, to do some communication and interaction with the outside world, if your flash is a completely separate file, no interaction and data communication with the outside, then you can not consider the cross-domain problem, because there is no cross-domain problem.
What is cross domain?
Cross-domain Simple is to access other domain name files or resources, such as a.com Flash to access b.com resources, it will cause cross-domain problems, because a.com and B.Com are not the same domain name.
Why is there a cross-domain problem? It's not just flash,javascript. Some scripts also have cross-domain problems, which are largely determined by their own security mechanisms, because accessing some files or resources across domains is risky, and he is beyond the scope of the site itself,
For the resources outside the station can not audit its security, in the network virus Trojan increasingly rampant today, cross-domain restricted access is an important solution to its security strategy.
What is the problem with Cross-domain?
There are a lot of problems with Cross-domain, the most direct is that the files accessed are limited, so that your flash will not work properly, so it is a very painful thing to people.
Now the Flash has not only as an animation, more data interaction, so communication with the outside as a more interactive medium to show, cross-domain is one of the problems that must be addressed. Well, maybe someone said, since there are cross-domain problems, then I put the resources under the same domain name is not OK?
Well, you can do this, but sometimes we also encounter access to external resources, and in a more formal project, Flash and HTML tend to be open, and many companies are the same, in order to facilitate maintenance and management, so cross-domain problems are easy to appear. 1, flash its own security mechanism settings: flash, in the IDE run is not any security restrictions, but released, there will be a lot of restrictions, Flash has 2 in the way, one is only to access the network, One is to access only the local, you can see in the file-Publish Settings-flash tab, note must be in the Flash file is valid when there is Oh, if the current edit is the as file is Wood has this selection menu: herehas limited the security level of flash, if you are only accessing the local, then all access to the Web in Flash will be banned, and only access to the network will be prohibited for local file access, so you choose according to the actual use, if you want your flash on the Web,
Then choose to only access the network, so you will be sure to test the testing in WebService, local run can be a variety of problems (if there is data communication), such as: Test urlhttp://127.0.0.1/123.swf.
2, ActionScript code settings:     AS2:Copy Code code as follows: System.security.allowDomain ("*");//for different HTTP resource System.security.allowInsecureDomain ("*"); For resources that require security verification, such as HTTPS AS3: Copy Code code as follows: Flash.system.Security.allowDomain ("*"); Flash.system.Security.allowInsecureDomain ("*"); The above is the strict writing, AS3 Fortunately said, we should pay attention to AS2,AS2 is Wood has flash.system this package, but you import Flash.system does not give an error, so if you copy the AS3 code into the run, although everything is normal, but the actual wood has any effect.
Be sure to pay attention! The above code is to allow flash access to any URL resources, if you want to access a specific URL, you can change the * to the URL, if more than one URL, separated by commas, note that Allowinsecuredomain is allowed access to the URL with authentication resources,
For example, HTTPS is the beginning, and if you are accessing just plain HTTP, you don't need it. 3, HTML settings: If you need and the page JS communication, then HTML must have such a parameter: copy Code code as follows: <param name= "allowScriptAccess" Value= "al
Ways "/> parameter always indicates that script access is always allowed, and if it is never, it is always disallowed. 4, load external resources: If you want to read an external file, such as Swf,picture,mp3, and so on, then need a Cross-domain policy file (crossdomain.xml), which is actually an XML file, the specific content is: copy CodeThe code is as follows: <?xml version= "1.0"?> <cross-domain-policy> <allow-access-from domain= "www.explorechn.com"/ > <allow-access-from domain= "explorechn.com"/> <allow-access-from domain= "223.4.119.191"/> </c Ross-domain-policy> This is the Cross-domain policy file, Allow-access-from domain represents a URL that is allowed to be accessed if there are multiple additions, if all is allowed on a allow-access-from domain = "
* "On it."
Need to explain this file how to use, if your flash in a.com, you need to access b.com resources, then put this XML in B.Com root directory can automatically access, of course, you can access other directory policy files. Copy CodeThe code is as follows: Flash.system.Security.loadPolicyFile (url:string);
Through this loadpolicyfile can take the initiative to load a security policy file, pay attention to the above is AS3, AS2 not the same Oh, refer to the above writing. 5, the various browsers across the domain problem: ie do not say, this basic no problem, including Flash itself generated HTML on IE support to do very well, here to say the problem of Chrome and FF: for Flash, IE is the object tag, but FF and chrome are recognized embed tags, so this is very important, if in debugging, find Firebug and other ToolTips "... is not a Function", we need to find the reason from: 1, addcallback whether successfully registered &NBSP;&NBSP;&NBSP;&NBSP;2, allowscriptaccess whether to allow always, the default does not allow
3, Flash is complete loading in general, the 3rd is our most easily encountered, if your flash did not load the completion of the call function, it is not found this function. Here you need to pay attention to another error hint, that is, "error calling method on Npobject", if this error occurs, be careful:
&NBSP;1, security policy issues, refer to all the solutions above 2, their own function errors