1 Reply Latest reply on Sep 12, 2012 7:03 AM by B4stien

    Loader not triggering events

    B4stien

      Hi everyone,

       

      I am not sure this is the right forum to post in. I am developing an inDesign extension in actionscript and I've drawing my own components which are supposed to retrieve an JPG image from the web and display it within the extension interface. I tried to use the Loader class to retrieve the image but none of the events are fired. Alternatively I tried using URLLoader, which does trigger events, but returns a ByteArray that I have to convert back to BitmapData. So I'm back to my original issue, my code in the "complete" event handler is never executed. Note that I tried to trigger "init", "progress", and "security error" as well, none of them are triggered. My code looks something like that:

       

      public class LayoutTileRenderer extends VBox

      {

         private var coverBitmapData:BitmapData;

            ...

       

         public function loadImage(imageByteArray:ByteArray):void{ 

              var bitmapLoader:Loader = new Loader();

              coverBitmapData = new BitmapData(84, 118, true);

              bitmapLoader.addEventListener(flash.events.Event.COMPLETE, function(e:flash.events.Event):void {

                   trace("Loaded completed");

                   coverBitmapData.draw(bitmapLoader);

                   // then draw the bitmap

              });

              bitmapLoader.loadBytes(imageByteArray);

         }

       

       

         override protected function commitProperties():void{

              super.commitProperties();

              ... // retrieve imageByteArray via URLLoader

              loadImage(imageByteArray);

         }

      }

       

      Does anyone have a clue why the events are not triggered. And otherwise has a better way of converting the bytes I get in my URLLoader to BitmapData for display?

       

      Thanks in advance for your help.