Techblog

Tech Blog

Our latest geek adventures!

7 May SWF’s, Javascript and subdomains

Today I had (actually I still have) an issue with subdomains, SWF’s and Javascript. For the Floorplanner we communicate with our Flash application via Javascript (using ExternalInterface). On www.floorplanner.com everything works fine, but when I tried to use a subdomain (like whatever.floorplanner.com) an error appeared. First I thought it was a Javascript error, but it turned out to be the Flash Security Sandbox blocking the communication.

To solve this I added the following line to the Flash app:

System.security.allowDomain('http://whatever.floorplanner.com/');

It did the trick, but the thing is that every (paying) user can create and use its own subdomain, so i needed something like this:

System.security.allowDomain('http://*.floorplanner.com/');

That didn’t work. After trying all kinds of different things like crossdomain.xml, I settled with

System.security.allowDomain('*');

This feels like a really nasty hack, but it’s all I can come up with. There has to be a better way…

5 Responses to “SWF’s, Javascript and subdomains”

  1. Folkert Says:

    wouldn’t just System.security.allowDomain(’floorplanner.com’); not work ?
    or else System.security.allowDomain(’*.floorplanner.com’);

  2. Ryan Christensen [draw.logic] Says:

    It would seem like that would work per this : http://www.flashguru.co.uk/systemsecurityallowdomain/ I haven’t used it much but I am digging in now and will need this soon. I wonder if it doesn’t like regular expressions? That would be ideal if it did.

  3. Gert-Jan Says:

    @Folkert: both ‘floorplanner.com’ and ‘*.floorplanner.com’ didn’t work… too bad

  4. Justin MacCarthy Says:

    Set System.exactSettings to false to allow subdomains

    Hope that helps. ..

    Justin

  5. Memento Says:

    have U tried this:
    Security.allowDomain(root.loaderInfo.loaderURL);

    cheers!

Leave a Reply