| |
|
|
|
|
|
|
Transferring data across domains using crossdomain.xml
In many occasions you might want a SWF to be able to retrieve data from another domain, by loading variables from a text file for example, or you might want to send data from a Flash email form to a PHP script that is sitting on another domain.
With Flash player 6 a security sandbox implemented a restriction : a movie sitting on one domain would be prevented from loading data from another domain. In Flash Player 6, sub domains of the same parent domain could access each other's data this is not the case anymore starting with Flash player 7, domains must be identical for data to be read.
Luckily there is a way to allow the Flash player to gather or send data from another domain, this is what we can find in the Flash 8 manual :
Here we are, let's have a look in more details at a crossdomain.xml :
You will notice the usual XML version declaration :
Then we have the tag that will encapsulates all the tags.
All the
tags have an attribute that can either specified an exact IP address, an exact domain, or a wildcard domain (any domain).
If you specify an IP address you will need your SWF file to access the data source using the ip address in the web address like , the Flash player won't do any DNS conversion so you can't just enter the domain name bound to that IP as it won't work.
Be aware that using won't grant access to the data source to your SWF if you try to access it using and vice versa. To be sure that you will be able to access it from both url, the one with the www and the one without it you will need to specify both domain or to use a wild card like
if you want to allow access to your server to all IPs and domain names just use a simple wild card as below :
If you have a data source sitting on HTTPS server and you want a SWF sitting on HTTP server to be able to access you will have to add the attribute to the tag as well as setting it to false (see example below)
If you want to be able to customize the location and the name of your policy file you can use
the System.security.loadPolicyFile method. This method will only work if the client is using a post Flash player
7.0.14.0.
With the addition of System.security.loadPolicyFile, Flash Player 7.0.19.0 can load policy files from arbitrary locations, as shown in the following example:
Good luck :)
|
|
If you think this page is providing useful information, don't hesitate to leave a comment.
|
|
|
|
|
|
|
|
|
Copyright ©2006-2008 flashvalley.com - All rights reserved |
|