Some of my relatives are PHP

So here’s an annoying little problem I came across on my most recent project.


In order to get around the Flash security sandbox of loading data across domains from within a Flash SWF I have to use a PHP script that gets an RSS XML feed and delivers it to Flash.

If the RSS information loads then it displays an RSS ticker tape of that feed. The call to this file was a relative call (i.e. just proxy.php) because the PHP file was in the same directory as the Flash. This is all fine and whizzy-jolly and everyone pats each other on the back and congratulates themselves on their sheer digital brilliance by fooling Flash’s security and we all have tea and cake.

However when I eventually finished the project and deployed on various test servers (it was actually designed for kiosks running IE8 so the target environment was a known quantity) I noticed that the XML wasn’t loaded and therefore the ticker wasn’t displaying in both Safari or Firefox;. it was fine in IE8.

I did notice however, that if I put an absolute URL like it worked across all browsers. I have tried a dozen different ways to address the PHP relatively but nothing worked for these browsers so here is my solution.


This basically takes the URL of the address bar, works out the root folder and adds ‘proxy.php’ to the end and hey presto! – it works.

Get the URL in the address bar using the ExternalInterface class and add the PHP file name:

function setProxyStub() {
if (ExternalInterface.available) {
try {
//full address
var my_url:String ="function(){return window.location.href}");
//proxy file name
var proxy_file:String = "proxy.php";
//the full address minus the bits after
//the root plus the proxy file name
var full_proxy_path:String = my_url.substr(0,my_url.lastIndexOf("/")) + "/" + proxy_file;
} catch (e:Error) {
} else {

This now gets around the issue of Firefox and Safari not accessing a PHP file relatively. This worked in IE before and after the fix. This solution also means the functionality is portable as long as the directory structure is the same.

Hope this helps someone!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s