title: Load profile image from Facebook with Actionscript 3
body: <p>I'm trying to load profile images (friend images) from Facebook with AS3 but I seem to be running into a security issue.</p>
  
  <p>I'm currently using the "official" <a href="http://www.adobe.com/devnet/facebook.html" rel="noreferrer">Adobe Facebook API</a> for Actionscript 3 which works fine. However, I seem to be having trouble loading profile images when running my application in a browser. The images load fine when running in the Flash IDE.</p>
  
  <p>The images are being loaded from <code>https://graph.facebook.com</code> and there seems to be a crossdomain.xml policy on that domain:</p>
  
  <pre><code>&lt;!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"&gt; 
  &lt;cross-domain-policy&gt; 
    &lt;allow-access-from domain="*" secure="false" /&gt; 
   &lt;site-control permitted-cross-domain-policies="master-only" /&gt; 
  &lt;/cross-domain-policy&gt; 
  </code></pre>
  
  <p>In other sources I found that adding a ContextLoader to my Loader object when loading the image should solve the problem but this doesn't seem to be the case either:</p>
  
  <pre><code>loader = new Loader();
  // add some listeners here...
  loader.load( new URLRequest( "imageurl" ), new LoaderContext(true) );
  </code></pre>
  
  <p>I'm not quite sure how to proceed at the moment. I was hoping that the Adobe Facebook API would provide assistance in this but I can't seem to find anything that solves this issue.</p>
  
  <p>Any help greatly appreciated.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I just noticed that when I visit one of the images in a browser that I'm actually redirected to Facebook's CDN where the actual image is stored. When I hard-code the image url with the redirected URL I can load the image in the browser. It seems that this is not a security issue after all but a redirection issue.</p>
  
  <p>If this is a redirection issue then the question would become; How can I have Flash Player load an image from a redirected URL?</p>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>It seems that the URLRequest class has a <a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/net/URLRequest.html#followRedirects" rel="noreferrer"><code>followRedirects</code></a> property which is only available in AIR.</p>
  
  <p><strong>UPDATE 3:</strong></p>
  
  <p>I'm currently using a <a href="http://w-shadow.com/blog/2008/07/05/how-to-get-redirect-url-in-php/" rel="noreferrer">PHP script</a> to get me the redirected URL as a work around but this of course is far from ideal and potentially a big strain on my server.</p>