3 Replies Latest reply on Jun 27, 2011 8:44 AM by kglad

    sendLV.img = compressArray(PixelAF(bmp)).toString();

    Ron Colmen Level 2

      I'm trying to convert a mc in to a jpg. But the images seems to be blank.

       

      //Frame1

      import flash.display.BitmapData;

      var itemA:Array = [holder1, holderX];

       

      function bitmap2F(mc:MovieClip){

          itemA.push(mc);

      }

      go.onRelase = function () {

      bitmap2F(holderX);

      gotoAndStop (5);

      }

       

      //Frame5

      import flash.display.BitmapData;

      import flash.geom.Matrix;

      var sendLV:LoadVars = new LoadVars();

      var receiveLV:LoadVars = new LoadVars();

       

      function saveBitmap2F(mc:MovieClip){

      sendLV.imageName = "itemN_"+itemNIndex+"_"+imageIndentifier;

      mc.cacheAsBitmap = true;

          sendLV.img = compressArray(PixelAF(bmp)).toString();

          sendLV.height = bmp.height;

          sendLV.width = bmp.width;

      sendLV.sendAndLoad("/saveImage.php",receiveLV,"POST");

      }

       

      function PixelAF(bmp:BitmapData):Array {

      var h = bmp.height;

      var w = bmp.width;

      var pixelA:Array = new Array();

      for (var a = 0; a<=w; a++) {

      for (var b = 0; b<=h; b++) {

      var tmp = bmp.getPixel(a, b).toString(16);

      pixelA.push(tmp);

      }

      }

      return pixelA;

      }

       

      function compressArray(orig:Array):Array {

      var compressedA:Array = [];

      var lei:Number = 0;

      for (var i = 0; i<orig.length; i++) {

      if (orig[i] != compressedA[lei]) {

      compressedA[i] = orig[i];

      lei = i;

      } else {

      compressedA[i] = "";

      }

      }

      return compressedA;

      }

        • 1. Re: sendLV.img = compressArray(PixelAF(bmp)).toString();
          kglad Adobe Community Professional & MVP

          that looks like my code.  did you get it from this forum?

           

          if so, did you get the php code too to decompress the jpg?

          1 person found this helpful
          • 2. Re: sendLV.img = compressArray(PixelAF(bmp)).toString();
            Ron Colmen Level 2

            Yes, it's one of your wonderful codes and also I've got the php.

             

            But I'm having some issues here in putting things together for my project. The jpg is always blank. (the mc I'm trying to is 700px x 300px).

             

            Thanks Kglad!

            • 3. Re: sendLV.img = compressArray(PixelAF(bmp)).toString();
              kglad Adobe Community Professional & MVP

              add an onData to receiveLV (see below), upload everything needed to your server and post the url.  also, make sure your php echos something.

               


              //Frame1

               

              import flash.display.BitmapData;

              var itemA:Array = [holder1, holderX];

               

              function bitmap2F(mc:MovieClip){

                  itemA.push(mc);

              }

              go.onRelase = function () {

              bitmap2F(holderX);

              gotoAndStop (5);

              }

               

              //Frame5

               

               

              import flash.display.BitmapData;

              import flash.geom.Matrix;

              var sendLV:LoadVars = new LoadVars();

              var receiveLV:LoadVars = new LoadVars();

               

              receiveLV.onData=function(src){

              trace(src);

              }

               

              function saveBitmap2F(mc:MovieClip){

              sendLV.imageName = "itemN_"+itemNIndex+"_"+imageIndentifier;

              mc.cacheAsBitmap = true;

                  sendLV.img = compressArray(PixelAF(bmp)).toString();

                  sendLV.height = bmp.height;

                  sendLV.width = bmp.width;

              sendLV.sendAndLoad("/saveImage.php",receiveLV,"POST");

              }

               

              function PixelAF(bmp:BitmapData):Array {

              var h = bmp.height;

              var w = bmp.width;

              var pixelA:Array = new Array();

              for (var a = 0; a<=w; a++) {

              for (var b = 0; b<=h; b++) {

              var tmp = bmp.getPixel(a, b).toString(16);

              pixelA.push(tmp);

              }

              }

              return pixelA;

              }

               

              function compressArray(orig:Array):Array {

              var compressedA:Array = [];

              var lei:Number = 0;

              for (var i = 0; i<orig.length; i++) {

              if (orig[i] != compressedA[lei]) {

              compressedA[i] = orig[i];

              lei = i;

              } else {

              compressedA[i] = "";

              }

              }

              return compressedA;

              }