Flexers,
We have an app that allows a user to upload images. When the user selects
an image, we load the bitmap from the hard drive and create a thumbnail from
it. However, every once in a while the bitmap will return 0 for both width
and height which causes issues later on. That vast majority of the time the
width/height are returned correctly.
Here's the basic code of the image loading--it's nothing special:
====================================
override public function execute():void
{
file.addEventListener(Event.COMPLETE, fileLoadedHandler);
file.addEventListener(IOErrorEvent.IO_ERROR,
fileLoadErrorHandler);
file.load();
}
/**
* The files bytes were loaded successfully.
*/
protected function fileLoadedHandler(event:Event):void
{
file.removeEventListener(Event.COMPLETE, fileLoadedHandler);
file.removeEventListener(IOErrorEvent.IO_ERROR,
fileLoadErrorHandler);
var ba:ByteArray = file.data;
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
bitmapLoadedHandler);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,
bitmapLoadFailedHandler);
loader.loadBytes(ba);
}
/**
* The bitmap was successfully loaded from the file's bytes.
*/
protected function bitmapLoadedHandler(event:Event):void
{
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,
bitmapLoadedHandler);
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,
bitmapLoadFailedHandler);
try
{
var fullSizeBitmap:Bitmap = Bitmap(loader.content);
if (fullSizeBitmap.width == 0 || fullSizeBitmap.height == 0)
{
// There's a problem.
}
...
====================================
Any idea why this would be the case? Is it a Flash Player bug? Any help
is much appreciated.
Aaron