It's not any particular photo or set of photos.  Sometimes we can run the
app and load the photos just fine then the next day we'll attempt to load
the same files and the width/height will return 0.  It seems that once the
issue starts to occur that any time we try to upload any photo within that
session it continues reporting width/height of 0. There's not a very
reproducible pattern though it seems to occur more frequently when the Flash
Player is under heavy stress like when it's trying to load in many files at
the same time.  It also seems to happen more frequently if we have two tabs
open with the same application loaded in both and we're attempting to load
the same images in both tabs (this may be related to the stress the Flash
Player is under rather than some sort of file locking issue).  Again, it
doesn't always happen, just more frequently under those scenarios.  We've
created a queue so only one photo is loading in at a time and we even threw
in the Grant Skinner hack of forcing garbage collection between each load to
see if that would help.  That did actually decrease the frequency of the
issue quite a bit but not sufficiently.

Since posting we've tweaked the code slightly to use the width/height
properties on the bitmapdata instead of the bitmap itself.  I doubt it will
make any difference but at least it narrows it down a bit.

Aaron

On Mon, Feb 22, 2010 at 1:05 PM, Alex Harui <[email protected]> wrote:

>
>
> Is there a particular file that gives you trouble or wil it load
> successfully at some other point?
>
>
>
> On 2/22/10 10:06 AM, "Aaron Hardy" <[email protected]> wrote:
>
>
>
>
>
>
> 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
>
>
>
>
>
> --
> Alex Harui
> Flex SDK Team
> Adobe System, Inc.
> http://blogs.adobe.com/aharui
>  
>

Reply via email to