1 Reply Latest reply on Nov 20, 2007 12:37 PM by mckenp1

    Using FABridge, Java Applet passing JPEG in byte Array to the Flex App

    Farman@Alpha
      Hi All,
      Following is the method, which I am calling from JavaScript, which is called by java applet.
      I am getting an error imgLoader.loadBytes(img) call, since it can't convert Object to ByteArray.
      Can anybody help me to resolve this issue or provide me any sample code, where I can pass byte [] from Java Applet to Flex App using FABridge?

      Thanks
      public function setInFlex(img):void
      {
      trace(img);
      imgLoader = new Loader();
      configureImgLoaderListeners(imgLoader.contentLoaderInfo);
      imgLoader.loadBytes(img);
      }
        • 1. Re: Using FABridge, Java Applet passing JPEG in byte Array to the Flex App
          mckenp1
          I'm hoping to find a way to do this as well.

          I *did* find a way to get this done, but it is far from perfect:
          In the java applet, encode the byte[] into a base64 String (implementation taken from java source).
          Return this string to your Flex app where you run a base64 decoder on it.
          I made mine from an old source file of mx.utils.Base64Decoder.as
          I cut everything out of this but a static decode method which returns the ByteArray instead of storing it in the decoder class, but its still too slow with large amounts of data.
          Now you can load it like a normal ByteArray, once the bytes are done loading of course.

          I read that ExternalInterface was really slow with large quantities of data, but my prototype didn't experience these kind of delays (700ms for 1.7Mb). ExternalInterface was probably optimized in Flash9.
          The problem I'm having is the decode time (2s for that 1.7Mb jpg)... much too long for what I'm trying to accomplish.

          If anyone finds away to transfer a java byte[] to flex ByteArray in a timely manner, please let us know.