开发者

Facebook data to DisplayObject in AS3

Is it possible to convert facebook data (ex. user_pic) i开发者_运维技巧nto 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.


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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜