2

(ActionScript3) Hi, I'm trying to work out why a URLRequest is failing when viewed via a third party website. Ideally any error could be pointed out in the below code, however, I think it's fine as similar things we do work fine.

Next to ideal would be URLRequest error handling, how can I find out WHY the URLRequest is not pulling the information from time.php? Even if it's just output to a textbox on the timeline (everything works fine when done from the testing environment)

Many thanks Craig

Scenario:

  • domain.com (Server 1): file.swf uses a URLRequest to load domain.com/time.php?a=b (so the PHP and the SWF are both hosted on the same domain and server)

  • example.com (Server 2): PHP page embedding file.swf (which in turn URLRequests time.php)

Outcomes:

  • When you access file.swf directly via browser, it loads the data from time.php just fine

  • When you view the page file.swf is embedded on, on Server 2 the loading fails


file.swf

var loaderNameHolder;
var loaderNameHolderLoader:URLLoader = new URLLoader();
var loaderNameHolderURLRqst:URLRequest = new URLRequest('http://domain.com/time.php?a=b');
loaderNameHolderLoader.addEventListener(Event.COMPLETE, loaderNameHolderURLFunc);
loaderNameHolderLoader.load(loaderNameHolderURLRqst);
function loaderNameHolderURLFunc(e:Event):void{
    loaderNameHolder = loaderNameHolderLoader.data
    gotoAndStop(loaderNameHolder);
}

Security

  • There is a crossdomain XML in place on the domain's root folder, it seems to make no difference (or is not being referenced/used correctly) however as mentioned similar things I do work fine without modifying this XML
Craig
  • 431
  • 1
  • 4
  • 12

3 Answers3

2

It sounds like a security issue, although you say that you have the crossdomain file in place.

Have you checked the http calls with a tool like Charles (http://www.charlesproxy.com/)? This is definitely the best way to debug such a problem.

Christophe Herreman
  • 15,895
  • 9
  • 58
  • 86
1

Thanks for the tips above, they'll be great resources to keep.

The actual issue was that the Requested URL didn't include "www" (I think because the SWF is embedded with the WWW so it was coming from an "outside" domain. I think I need www.domain.com in my own security XML).

Craig

Craig
  • 431
  • 1
  • 4
  • 12
  • I can confirm that; Though they will generally be treated/behave in the same way, two URIs like `http://www.domain.com` and `http://domain.com` are by definition pointing to two separate domains. – Kjartan Apr 04 '13 at 10:05
0

try adding this code

Security.allowDomain("*");
Security.loadPolicyFile("http://domain.com/crossdomain.xml");

and read about crossdomain.xml using links given here: https://stackoverflow.com/a/9728845/2234089

Community
  • 1
  • 1
Roman
  • 189
  • 1
  • 6
  • Thanks, I've posted the end solution but the info in that link will be a great resource. – Craig Apr 04 '13 at 09:50