views:

207

answers:

1

Is it possible to convert facebook data (ex. user_pic) into a DisplayObject so I can be easier to manipulate? What I m trying to do is when users do FacebookConnect in my site to let them have the possibility to scale their image (like transform tool usage) before submit it in a gallery.

A: 

Update: It turns out that OP already has the image in a UILoader. In that case, you can access it using the content property of UILoader

var img:Bitmap = Bitmap(uiLoader.content);
var bitmapdata:BitmapData = img.bitmapData;

You can load the user picture to your SWF using a Loader object and manipulate it, provided the image is hosted in a sever that allows SWFs from your domain to access contents using appropriate crossdomain.xml.

If you know the location of policy file, call Security.loadPoliCyFile before loading image. Flash player will try to load it from the default location /crossdomain.xml

Security.loadPolicyFile(policy-file-url);

var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad);
ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
ldr.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError);
ldr.load(new URLRequest(the-image-url);

function onError(e:Event):void
{
  trace(e);
}
function onLoad(e:Event):void
{
  //this will fail if there is no crossdomain.xml file at
  //the image's originating server.
  var image:Bitmap = LoaderInfo(e.target).content as Bitmap;
  var bitmapData:BitmapData = image.bitmapData;
  //do whatever you want with the bitmap data here
  addChild(image);
}
Amarghosh
Thanks for your answer. The fact is that I load data with the Facebook GetInfo method and store them in a variable like that: pUser.pic_big; I don't have the exact URL for each picture. I use a UILoader component to add the image on stage through the UILOader.source=pUser.pic_big method but I cannot scale it or transform it at runtime.
Dimitree
@dimitree if you already have it on stage, you can access it using `uiLoader.content`
Amarghosh
This means can I transform it and save the new image in my server?
Dimitree