// forked from undo's facebookのアイコン画像ロード→BitmapData.draw
package
{
import flash.display.*;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.utils.ByteArray;
[SWF(width=465,height=465,backgroundColor=0x000000,frameRate=60)]
public class ASTest extends Sprite
{
private var _urlLoader:URLLoader;
public function ASTest()
{
this.addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(evt:Event = null):void
{
_urlLoader = new URLLoader();
_urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
var req:URLRequest = new URLRequest('http://graph.facebook.com/undo0530/picture');
_urlLoader.addEventListener(Event.COMPLETE, onComp);
_urlLoader.load(req);
}
private function onComp(evt:Event):void
{
var loader:Loader = new Loader();
var byteArray:ByteArray = _urlLoader.data as ByteArray;
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComp);
loader.loadBytes(byteArray);
addChild(loader);
}
private function onLoaderComp(evt:Event):void
{
var loader:Loader = evt.target.loader as Loader;
var bmd:BitmapData = new BitmapData(loader.width, loader.height);
bmd.draw(loader);
var bmp:Bitmap = new Bitmap(bmd);
addChild(bmp);
bmp.x = loader.width;
}
}
}