I would like to display an Image using a Bitmap as source. I’ve been suggested something akin to this but somehow it still doesn’t work.
img1 works fine… But img2 doesn’t load for some reason.
private function onComplete(event:Event):void{
_bytes = event.target.data;
img1.source = _bytes; /*this last bit works*/
_bmpData = new BitmapData(img1.width,img1.height);
_bmpData.draw(img1,new Matrix());
_bmp = new Bitmap(_bmpData);
img2.source=_bmp;
}
img2.source=_bmp;doesn’t work because you can’t pass a Bitmap object to the source property of an Image control. From the documentation:A Bitmap is a DisplayObject, but it does not implement IFlexDisplayObject, so instead of using
Image.sourceyou can add the Bitmap as a child of the Image: