views:

52

answers:

3

This is an ActionScript 3 problem...

I am hosting a swf on my.domainA and I am requesting a jpg from my.domainB ( of course I'm obsfucating the domain names ) the using this code:

var request:URLRequest = new URLRequest(result.image); request.requestHeaders.push(header); var context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain, SecurityDomain.currentDomain); content = new Loader(); content.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded); content.load(request, context);

Domain B has a cross domain xml file which looks like this:

" " - having problems getting stackoverflow to show the xml but it's standard allow-access-from domain="*" policy file

However, I get this error: "Error: [strict] Ignoring policy file at my.domainB.com/crossdomain.xml due to bad Content-Type 'binary/octet-stream'. See www.adobe.com/go/strict_policy_files to fix this problem."

Does anyone have any idea how I can resolve this? Is this bad Content-type for the crosdomain.xml file or the jpg I am requesting?

Any help appreciated.

A: 

A first guess would be that your crossdomain file is being rejected, rather than the jpg.

In your code we can't see the content of your header variable... could the problem come from the way your request is handled?

Have you tried a simpler approach? Something like: var request:URLRequest = new URLRequest(result.image); var content:Loader = new Loader(); content.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded); content.load(request, new LoaderContext(true));

PatrickS
Sorry my bad... I added the header variable in an attempt to resolve the problem. My original code was:var request:URLRequest = new URLRequest(result.image);var context:LoaderContext = new LoaderContext(true, ApplicationDomain.currentDomain, SecurityDomain.currentDomain);content = new Loader();content.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);content.load(request, context);I have tried replacing the last line ( as suggested ) with:content.load( request, new LoaderContext(true) );but alas I still get the same error.
I've replaced the crossdomain.xml with a copy of another one which is being used on live projects to remove any potential encoding issues but still no positive result.
In the console after the error I do get a *** Security Sandbox Violation *** but I think that is because flash is "Ignoring policy file at my.domainB.com/crossdomain.xml due to bad Content-Type 'binary/octet-stream'" - emphasis on IGNORING.Sometimes I wish Flash was a little less strict!!!
I should also mention the content requested is hosted on a 'content delivery network' namely akamai
I was wondering about the header variable because the error seems to have to do with the Content-type of the crossdomain.xml . One would expect application/xml or text/xml... I assume that result.image is the url of the jpeg you want to laod
PatrickS
A: 

I've done some more research into this problem and I can't find anything the same, however using a content delivery network such as Akamai may be contributing to the problem: http: / / jessewarden.com/2009/03/handling-crossdomainxml-and-302-redirects-using-netstream.html

I've tried changing my code so there is no request for content and all I am doing is requesting the crossdomain.xml:

var policyFileURL:String = "http://resources-ms-ak.myDomainB.com/crossdomain.xml"; Security.loadPolicyFile(policyFileURL);

Unfortunately I still get: Error: [strict] Ignoring policy file at http: / / resources-ms-ak.myDomainB.com/crossdomain.xml due to bad Content-Type 'binary/octet-stream'

Again, any ideas people? :-S

A: 

I've never had this problem, but the message seems to indicate that the problem is that the crossdomain file is served with the wrong content-type (binary/octet-stream instead of text/xml). Can you check that? A simple way would be loading the xml with looking at the response headers with firebug (or some other tool).

By the way, you are loading an image. Probably you are aware of this, but just in case: if you don't need to manipulate the image pixel data, you can just load it without a crossdomain. Just don't try to create a BitmapData image from it and don't access loader.content either. Place the image on the display list (or remove it) through the loader object, that is a display object and can act like a "proxy" for the real image.

Juan Pablo Califano
The crossdomain.xml is an exact copy of a live crossdomain xml which works fine. However the one that works is not on a CDN. I'm wondering if Akamai is not serving it correctly like you suggested.I realise no policy is required for a jpg - I switched to jpg from an swf to see if the error was caused from serving a swf. I need to talk to that swf so a policy is required unfortunately.I have proved the model by switching the required content (in this example the jpg on 'domainB') to one of our servers and the code works beautifully so it appears the issue ties in with the CDN.
In response to looking at the response, looking at the working from firebug, there is no error reported when GET'ing the crossdomain xml, but if I look at the response there is nothing there. :-S
We might be able to set up proxy server to get content from the CDN but it'd be a shame to go to all that trouble only to find that doesn't work too
@lukeluke. The problem seems to be not in the xml file itself, but rather on how it's been served (wrong content-type headers). But you say you can't see any content for the crossdomain.xml. That could be the problem then. I'd suggest you contact the CDN provider if possible, since it seems for your description that the crossdomain is either not being served or its served with the wrong headers.
Juan Pablo Califano
@lukeluke. Yeah, proxying your requests to the CDN defeats the whole point of using a CDN in the first place. So although it might work, you would not want to go that route.
Juan Pablo Califano
@lukeluke. By the way, I'm not sure you can do this, but if you can, maybe posting the url to the problematic crossdomain could help me or other people to see the problem.
Juan Pablo Califano