Why aren't my external resources loaded (in many cases) via URL / Loaders in ActionScript?

I am developing a Flash game that loads resources from a local url. This url is resolved locally and something like http://example.dev . This only contains static resources, so something like http://example.dev/images/randomtiles/grass.png is actually a valid image if I got into the resource via curl

.

However, I am using two browsers for testing. One is Google Chrome with Adobe Flash Player 15.0.0.189 and the other is Firefox with Adobe Flash Player 11.2.202.457. I am using Ubuntu 14.04 (this may be a bug, not an 8-layer problem).

In AFP 15, clicking on the URL http://example.dev/images/randomtiles/grass.png doesn't work at all. In AFP 11, clicking on the url http://example.dev/images/randomtiles/grass.png only works if I am connected to the internet. Clicking on a URL with curl

always works. Clicking on a URL from Chrome or Firefox directly always works.

The mechanism used to get images through Flash explains a bit, but it is mostly based on Loaders:

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void {
    try {
        addCacheCallback(entry, Bitmap(LoaderInfo(e.target).content));
    } catch(e:Error) {
        errorCallback(e);
    }
});
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorCallback);
loader.load(new URLRequest("http://example.dev/images/randomtiles/grass.png"));

      

What i expect . Since the resource server is maintained locally (on this machine), I expect my service to always have resources regardless of the flash version.

What's going on with Flash Player? Or ... what did I miss there? (Can't debug due to environmental issues, which I'm still afraid of).

+3


source to share


1 answer


Is your file .swf

from the same domain?

If not, you need to add the file crossdomain.xml

to your site. This documentation might help.

The easiest way to check if this is the problem you are facing is to add a file named crossdomain.xml

to the root of your site:



<?xml version="1.0"?> 
<!-- http://www.foo.com/crossdomain.xml --> 
<cross-domain-policy> 
  <allow-access-from domain="*" /> 
</cross-domain-policy>
      

Run code


Note that in practice, you need to specifically set up a whitelist of domains to be allowed access.

0


source







All Articles