8 Replies Latest reply on Dec 13, 2011 12:48 PM by drkstr_1

    bytearray to image?

    flex login screen Level 1

      i am trying to display bytearray as image in spark image control.

      my code is

           

               

      public function getImage(bytes:ByteArray,context:LoaderContext = null):void

      {

          var loader:Loader = new Loader();

          loader.loadBytes(bytes,context);

          loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteHandler);

      }

      private function loaderCompleteHandler(evt:Event):void {

          var t:LoaderInfo = evt.currentTarget as LoaderInfo;

          // display the jpeg in an Image component

          patientInfo.img.source = t.content;

      }

       

      but i get the following script error;

       

      An ActionScript error has occurred:

      Error #2044: Unhandled IOErrorEvent:. text=Error #2124: Loaded file is an unknown type.

       

      how can i resolve this?

      pls reply.