title: Action Script 3, Graph API - Load Facebook avatar, then use JPGEncoder to save image
body: <p>im trying to load my facebook display image and then save it through as3 using JPGEncoder. </p>
  
  <p>Right now im getting the image url and through a Loader, adding the image to a movie clip called foto1. This is working fine:</p>
  
  <pre><code>var image:URLRequest = new URLRequest("http://graph.facebook.com/" + response[0].id + "/picture?type=large");
  imageLoader.load(
  foto1.addChild(imageLoader);
  </code></pre>
  
  <p>The problem is when i try this:</p>
  
  <pre><code>var myImage:Bitmap;
  var jpgSource:BitmapData = new BitmapData (foto1.width, foto1.height);
  jpgSource.draw(foto1);
  
  var jpgEncoder:JPGEncoder = new JPGEncoder(n);
  var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);
  
  var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");
  
  //Make sure to use the correct path to jpg_encoder_download.php
  var jpgURLRequest:URLRequest = new URLRequest ("http://www.thewebchi.mp/pruebas_graph/download.php?name=" + fileName + ".jpg");
  jpgURLRequest.requestHeaders.push(header);
  jpgURLRequest.method = URLRequestMethod.POST;
  jpgURLRequest.data = jpgStream;
  
  var loader:URLLoader = new URLLoader();
  navigateToURL(jpgURLRequest, "_blank");
  </code></pre>
  
  <p>If i try the jpg process on movie clip 'foto1' without loading the external image, it works fine.
  When i load the image to 'foto1' the jpg process doesnt respond.
  Thank you very much!!!</p>