Select Page

So there was this little issue I ran into with Flex and image processing. When posting an image to the flash player client, instead of uploading to a server (save on bandwidth when editing locally) it would show that the image was loading, however with security errors (via the debugger).

Anywho, the problem was actually simple where the image was not being fully loaded as the flash swf was playing. So to rectify that issue, I simply added an event listener to wait for the image load to complete, and then move on to create a bitmap.

Now you will see in the code below that I am already using an image control, however this was used with bytesarray, and of course with FileReference.load() method.

Anywho, I hope this helps some people out there. I saw other solutions on other forums where people were setting timer’s to wait for the image or set a bland method that allows the player an extra second to capture the image, instead of quickly passing through it.

private function completeHandler(event:Event):void
var image:Image = "file.png";

// event listener
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
private function loadComplete(event:Event):void
// create bitmapdata
var bitmapData:BitmapData = new BitmapData(loader.width, loader.height);
bitmapData.draw(loader, new Matrix);

// create the new bitmap
var newBitmap:Bitmap = new Bitmap(bitmapData);