2 Replies Latest reply on Mar 6, 2008 10:51 PM by Flex-Issac

    Show Image by byte array

      Hi All,

      I have jpg file need to received in socket connection, it would received in bytearray. Then how can I display it in Flash? I found Image class only accept actual path and URL. How can it read bytes or other class can show the jpg file?

      Thanks All.
        • 1. Re: Show Image by byte array
          jylaxx Level 1
          Don't know if it is THE answer but this is working for me :
          (take time to find so thanks to feedback me if any better way to do it...)

          private var imgLoader : Loader = new Loader() ;

          private function getImg( source : ByteArray )
          imgLoader.loadBytes( source ) ;
          imgLoader.contentLoaderInfo.addEventListener( event.COMPLETE, imgLoaded ) ;

          private function imgLoaded( event : Event ) :void
          // photo is an Image object
          photo.graphics.beginBitmapFill( Bitmap( imgLoader.content ).bitmapData ) ;
          photo.graphics.drawRect( 0, 0, photo.width, photo.height ) ;
          photo.graphics.endFill() ;
          • 2. Re: Show Image by byte array
            Flex-Issac Level 1

            This method is work.