im trying to load my facebook display image and then save it through as3 using JPGEncoder.
Right now im getting the image url and through a Loader, adding the image to a movie clip called foto1. This is working fine:
var image:URLRequest = new URLRequest("http://graph.facebook.com/" + response[0].id + "/picture?type=large");
imageLoader.load(
foto1.addChild(imageLoader);
The problem is when i try this:
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 u开发者_如何学编程se 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");
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!!!
Is it necessary to use navigateToURL (opening in the browser window)? If not, I would suggest using the URLLoader, loader.load(jpgURLRequest)
. Also, using this approach you can listen for IOErrorEvent.IO_ERROR
on the loader (and other events) that may give you some hints on what is wrong.
精彩评论