2 Replies Latest reply on Mar 13, 2013 3:51 PM by clint.modien

    HTTPservice send Error: #2006

    Revlex Level 1

      Hi al,

       

      Im trying to send data from my flex app to my PHP back-en.

      My question is what am i doing wrong?

      I did figure out when it get's to the line of send_data.send(obj); it goes wrong(Please see the error below),

      i also figured out it does add the base64 encoded image to the object.

       

      What im doing wrong to generate this error i dont know, want somebody please push me in the right direction?

       

      Error:

       

      [RPC Fault faultString="Error #2006: The supplied index is out of bounds ." faultCode="InvokeFailed" faultDetail="null"]
          at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\gumbo_beta2\frameworks\project s\rpc\src\mx\rpc\AbstractInvoker.as:394]
          at mx.rpc.http::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::invoke()[E:\dev\gumbo_beta2\frameworks\project s\rpc\src\mx\rpc\http\AbstractOperation.as:1056]
          at mx.rpc.http::AbstractOperation/sendBody()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\ mx\rpc\http\AbstractOperation.as:896]
          at mx.rpc.http::HTTPService/send()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\htt p\HTTPService.as:869]
          at Iredaction/btn_publish_clickHandler()[C:\Users\Rens Visser\Desktop\Iredaction\Vbzdn\src\Iredaction.mxml:679]
          at Iredaction/__btn_publish_click()[C:\Users\Rens Visser\Desktop\Iredaction\Vbzdn\src\Iredaction.mxml:1079]

       

      i use this code in my MXML file:

       

      protected function btn_publish_clickHandler(event:MouseEvent):void
      {
      var obj:Object = new Object();

       

      if(img.source != null)
      {   
           var img_bitmap:Bitmap = new_image_s(img.content);
           var bst:String = f_corner_rounder(img_bitmap, 50);
           obj.img_1 = bst;

      }

      send_data.send(obj);

      }

       

              public function new_image_s(big_image:DisplayObject):Bitmap
              {
                  var width:int = big_image.width;
                  var height:int = big_image.height;
                  var scaleMatrix:Matrix=new Matrix();
                  big_image.transform.matrix = scaleMatrix;
                  big_image.cacheAsBitmap = true;
                  scaleMatrix.scale(66, 66);
                 
                  var scaledBitmapData:BitmapData=new BitmapData(width,height);
                 
                 
                  scaledBitmapData.draw(big_image)
                     
                  var bmp:Bitmap = new Bitmap(scaledBitmapData);
                 
                  var bmp_d:BitmapData = new BitmapData(bmp.width, bmp.height);
                  bmp_d.draw(bmp, null, null, null, null, true);
                  var bmp_r:Bitmap = new Bitmap(bmp_d);
                 
                  return bmp_r;
              }

       

      private function f_corner_rounder(org_bitmap:Bitmap, corner_size:Number):String
                              {
                                      var jpgEncoder:PNGEncoder = new PNGEncoder();   
                                      var encode_data_2:Base64Encoder = new Base64Encoder();
                                      var movieclip:DisplayObjectContainer = new MovieClip;
                                      var bitmapdata:BitmapData = new BitmapData(org_bitmap.width ,org_bitmap.height);
                                      var bit_map:BitmapData = new BitmapData(org_bitmap.width, org_bitmap.height,true, 0x00FF00);
                                      var loaded_bitmap:Bitmap = new Bitmap;
                                      var the_mask:Shape = new Shape;
                                      the_mask.graphics.moveTo(corner_size,0);
                                      the_mask.graphics.lineStyle(0,0,0);
                                      the_mask.graphics.beginFill(0xFFFFFF);
                                      the_mask.graphics.lineTo(org_bitmap.width - corner_size, 0);
                                      the_mask.graphics.curveTo(org_bitmap.width ,0, org_bitmap.width, corner_size);
                                      the_mask.graphics.lineTo(org_bitmap.width, org_bitmap.height - corner_size);
                                      the_mask.graphics.curveTo(org_bitmap.width, org_bitmap.height, org_bitmap.width - corner_size, org_bitmap.height);
                                      the_mask.graphics.lineTo(corner_size, org_bitmap.height);
                                      the_mask.graphics.curveTo(0, org_bitmap.height, 0, org_bitmap.height -corner_size);
                                      the_mask.graphics.lineTo(0, corner_size);
                                      the_mask.graphics.curveTo(0, 0, corner_size, 0);
                                      the_mask.graphics.endFill();
                                      org_bitmap.mask = the_mask;
                                      movieclip.addChild(org_bitmap);
                                      bit_map.draw(movieclip);
                                      loaded_bitmap.bitmapData = bit_map;
                                      var jpgStream_2:ByteArray = jpgEncoder.encode(bit_map);   
                                      encode_data_2.encodeBytes(jpgStream_2);
                                     
                                      var stringetje:String = encode_data_2.toString();
                                      return stringetje;
                              }

       

      <fx:Declarations>

              <mx:HTTPService id="send_data" resultFormat="text" showBusyCursor="true" method="POST" url="upload.php" />

       

          </fx:Declarations>

      <mx:Image x="525" y="559" mouseOut="btn_publish_mouseOverHandler_out(event)"   mouseOver="btn_publish_mouseOverHandler(event)" source="buttonpubliceren.png" width="150" height="30" id="btn_publish" click="btn_publish_clickHandler(event);" />