Facebook数据到AS3中的DisplayObject

时间:2010-03-05 13:48:42

标签: actionscript-3 facebook displayobject

是否可以将facebook数据(例如user_pic)转换为 DisplayObject ,这样我可以更容易操作? 我想要做的是当用户在我的网站上执行 FacebookConnect 时,让他们有可能在图库中提交之前缩放图像(比如转换工具使用)。

1 个答案:

答案 0 :(得分:0)

更新:事实证明OP已经拥有UILoader中的图像。在这种情况下,您可以使用content

UILoader属性访问它
var img:Bitmap = Bitmap(uiLoader.content);
var bitmapdata:BitmapData = img.bitmapData;

您可以使用Loader对象将用户图片加载到SWF并对其进行操作,前提是图像托管在服务器中,该服务器允许您域中的SWF使用相应的crossdomain.xml访问内容。 / p>

如果您知道政策文件的位置,请在加载图片前致电Security.loadPoliCyFile。 Flash播放器会尝试从默认位置/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);
}