Last updated on February 9th, 2022 at 02:32 pm

Hello guys i am back again with another nice set of tutorial based on Flash and actionscript. I am getting lot of emails from my users asking about the crossdomain technique in flash and how to make that work. When i searched google i was unable to find even a single perfect document that clearly says what we should do in this case.

Note: I don’t think anyone is using flash/swf files any more. But just keeping this tutorial since it has helped more than 35K visitors. (May be a reference)

Lets take a simple example

In orkut we have a flash scrap option. We can post scraps which is actually embedded SWF files.So lets take a scenario in which i have developed a Flash file[SWF] which reads my friends photo album which he has uploaded in Picasa.The logic behind it is my PHP script will read my friends picasa RSS page and create an XML data output.This XML data is read by my flash file which is a slideshow app.So when i upload these files mainly PHP, XML and also the SWF in my server say SERVER A it will work fine.Lets say i uploaded the files in the album folder of SERVER A

So i can access the file from<SWFNAME>.SWF

It will load fine with the SWF file perfectly showing the slideshow.

Now we will consider the scenario in which i am trying to scrap the swf embedded say in ORKUT.

<EMBED src="<SWFNAME>.SWF" quality="high" scale="noscale" bgcolor="#333333"  WIDTH=450 HEIGHT=450 TYPE="application/x-shockwave-flash" PLUGINSPAGE=""></EMBED>

Now this SWF file will get loaded in scrap, but unfortunately you wont be able to view any photos in the album.It will be blank.This means that XML is not properly loaded.So there is something that is preventing the SWF to read the data.There is a work around for this condition.That is achieved by using crossdomain.xml and also by adding a little bit of some security info in ur flash action script.

Now create crossdomain.xml file and add this lines below.

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy
<allow-access-from domain="*" />

Put this crossdomain.xml file in your server root directory.

Add the below lines in your actionscript page in the flash."*");"*");"");

What prevented ORKUT from displaying the SWF?

Just simple there is security enabled in flash and to overcome this we have specified in the crossdomain.xml to
allow-access-from domain=”*” or allow-access-from domain=”” or allow-access-from domain=”*”

* –> Can be any domain [You are allowing any domains to access your SWF and its data] ->Specifically means that only
can access.
* ->Means any subdomains of Orkut along with is allowed.

This will fix your issue.Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *