Flex HTML Post Error - Security Problem?
I have a swf that I have created that make a few HTML posts. When I run and compile the swf locally, it successfully makes posts to my php code hosted on my domain. However when I then upload my swf to my domain, and then alter the embed tag to have a fully qualified path to my hosted swf, the swf will load correctly but it will make any HTML posts to my PHP scripts. The reason that I have an an embed tag with the fully qualified url in it, is that my goal here is to be able to place the html embed code on a number of different sites.
I have it working on a single remote site, and it has a wild card crossdomain.xml file in it. However when I try to apply a crossdomain.xml to any of the hosted sites, or to my computer locally nothing runs when the I use the embed with the fully qualified URL, if I just the locally hosted swf on my computer the HTML post work just fine.
I feel this is related to the crossdomain.xml file, however I guess I'm not understanding some aspect of the security model.
So my goal is to be able to paste the embed HTML code with a fully qualified swf (for example, "htt开发者_如何学Cp://www.abc.com/myswf.swf") on a number of other sites and have it make standard HTML posts to my home site (http://home.com).
Thanks for any help on this one. I'm soooooo close, like I said I got it working on one remote site, but I'm not sure how. All other sites I post the embed code fail.
Ok , I'm editing my answer , following the examples you've just given.
According to the error report I get , the problem is with an ExternalInterface call that's not allowed from the swf to the site hosting your swf.
It works in the second example because the call is made within the same sandbox.
Taken from the docs:
SecurityError — The containing environment belongs to a security sandbox
to which the calling code does not have access. To fix this problem,
follow these steps:
In the object tag for the SWF file in the containing HTML page,
set the following parameter:
<param name="allowScriptAccess" value="always" />
In the SWF file, add the following ActionScript:
flash.system.Security.allowDomain(sourceDomain)
You may also have to check the allowNetworking parameter in your embed code...
精彩评论