My Flex application has an "insert image" feature which uses flash.display.Loader
to read an image from a ByteArray
like so:
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.loadBytes(fileRef.data);
This works fine except when a very large image is selected, in which case neither the COMPLETE nor IO_ERROR event handlers are called and no exception is thrown.
The only reference to a size limit I can find is in the BitmatpData documentation (I'm on Flash Player 14):
Starting with AIR 3 and Flash player 11, the size limits for a BitmapData object have been removed. The maximum size of a bitmap is now dependent on the operating system.
My problem is that I have no idea how to detect when a user selects a file that's too large in order to notify them. Right now the application just does nothing which can be pretty confusing.