R – Flex – get bitmap

actionscript-3apache-flexbitmapbitmapdata

Is it possible to get the bitmap data from a component using ActionScript?

I dynamically load an image.
onComplete I create a Flex Image component and add the loaded image to the source

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void 
{
     var image:Image = new Image();
     image.x = 0;
     image.y = 0;
     image.source = e.currentTarget.content;
     canvas.addChild(image); // canvas is already added as an MXML element.
 }

Later I want to create a new Image component and get the bitmapData from the first Image.

I have tried this

canvas.getChildAt(0)

Which seems to give me the Image, but I can not figure out how to get the bitmap data.

canvas.getChildAt(0).bitmapData; 

gives me a compile error "… undefined property"

Does anyone know how ot get the bitmap data so I can use it in my new Image component?

Thanks in advance,

Ran

Best Answer