Skip navigation
elenaalex
Currently Being Moderated

LoaderInfo class doesn't dispatch Init and Complete events

Mar 26, 2010 1:12 PM

Hi,

I use the traditional way to download jpeg images (size < 200K) dynamically:

 

{
    ...
    
    try {
     contentLoader = new Loader();
     contentLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
     contentLoader.contentLoaderInfo.addEventListener(Event.INIT, onInit);
     contentLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERRO R, onError);
     contentLoader.loadBytes(loader.data as ByteArray);
    } catch (error:Error) {
       trace (error.toString());
    }
}

private function onInit(event:Event):void {
     trace ("onInit");
}

private function onLoadComplete(evt:Event):void {
     token.result = (evt.target as LoaderInfo).content as Bitmap;
     ...
}

 

I have noticed that sometimes class LoaderInfo doesn't dispatch neither INIT nor COMPLETE event working with the same images. There is no IO_ERROR dispatched as well. All images are small (< 200K).

 

I suppose that this is a bug in the Flash Player.

 
Replies
  • Currently Being Moderated
    Mar 26, 2010 1:21 PM   in reply to elenaalex

    I think if your JPG image dimensions are out of range you won't get these

    events.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 26, 2010 3:21 PM   in reply to elenaalex

    Sorry, didn't see this response first.  How are you adding your event

    listener?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 29, 2010 2:53 PM   in reply to elenaalex

    That is about using loadBytes.

     

    Does a specific JPG fail to dispatch COMPLETE or will it succeed sometimes

    and fail other times?  If a JPG always fails, compare its dimensions with

    ones that work.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 17, 2013 5:38 PM   in reply to elenaalex

    Was there any resolution to this?

     

    I'm seeing this in Air 3.6, where loaderInfos with a very small byteArrays (~2k) will have a bytesLoaded and bytesTotal are equal immediately after invoking loadBytes, but the loaderInfo will never subsequently trigger the completion or init events.

     

    Although it's 100% repro case for us, it's not 100% with the same swf - in a smaller test case the particular swf loads fine.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2013 10:19 PM   in reply to joe_valenzuela

    What are you loading?  A small SWF or just data?  SWFs use Loader, but data uses URLLoader.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2013 10:23 PM   in reply to Flex harUI

    A small swf.  It loads under other circumstances - like when trying to make a test case, but after loading a lot of other swfs via Loader.loadBytes, this particular swf fails to trigger the complete event.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2013 10:26 PM   in reply to joe_valenzuela

    SWFs have a main class name.  Depending on the LoaderContext options, if the same SWF has already been loaded or another SWF has the same main class name, then it will not finish loading.

     

    Also, if you did not properly keep a hard reference to the Loader, the execution of the SWF can cause garbage collection and punt the Loader.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2013 10:36 PM   in reply to Flex harUI

    What's the LoaderContext option that will prevent the SWF from loading if another swf has the same main class name?  In my test case I can actually load quite a few of these in the same frame, so I'm not inclined to think that's the problem, but I'd love to rule that out.

     

    I've tried attaching an ENTER_FRAME event listener to these troublesome loaderInfos as well, and inspecting them several frames later shows them to be in that same state - bytes ostensibly fully loaded, but no events triggered.  So I'm reasonably sure they aren't being collected.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2013 12:18 PM   in reply to joe_valenzuela

    As long as you haven’t set LoaderContext’s applicationDomain to ApplicationDomain.currentDomain it will grant the SWF its own set of classes.

     

    Are these Loader instances on the display list?  How are you attaching the listeners?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2013 4:42 PM   in reply to Flex harUI

    Okay, at this point I think I can chalk it up to a bad swf file (or a couple, anyway).

     

    One thing I noticed while stepping through fdb is that after invoking loader.loadBytes, even though the completion event is never triggered, it looks like a new swf is instantiated.  The instantiated movieClip is ~600k, though, which is over 200 times the actual source file size.  Using swfdump from the flex sdk on the swf it looks like the framerate and length parameters were bad.  Like 20k and 600k bad.  I'm guessing the file was incorrectly stored as text at a point.  After checking the source asset and reexporting, my application works as expected (the loaderInfo always triggers a completion event).

     

    I'm not sure why it works when in an isolated test case.  I end up loading the file the same number of times.  There's definitely a concatenation of circumstances at work.  I guess it's possible if I let it run for an indefinite amount of time the event would have eventually triggered.

     

    Thanks for the time though.  Hopefully someone else finds this thread helpful.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points