2 Replies Latest reply on Sep 27, 2010 2:22 PM by crawler486

    Help Splitting Image

    crawler486

      Hello Guys,
      I'm new to ActionScripts and was tasked to complete a project. I'm  trying to split a big image so I can send them to a http server in  chunks. I'm using a recursive function below and increasing the  DisplayObjects X position on every iteration. The problem is I get the  same image in every iteration and checking the encodeByteArray string  value is always the same. Below is the code and would appreciate if any  one can give me a clue as to why this is happening.

      Code:

       

      var currentTileIndex:int = 0;

           function renderNextTile(e:Event):void{
                if(currentTileIndex < tilesToLoad){
                     loader = new URLLoader();
                     loader.addEventListener(Event.COMPLETE, renderNextTile);
                     loader_txt.text = currentTileIndex + "% Rendered";
                     //loadingBar_mc.percentComplete_mc.scaleX = Number(currentTileIndex/100);
                     zoomContainer_mc.mainContainer_mc.x = -40*currentTileIndex;
                     
                     trace("Compass : x="+zoomContainer_mc.mainContainer_mc.x);
                     trace("Compass : y="+zoomContainer_mc.mainContainer_mc.y);
                     
                     var jpgSource:BitmapData = new BitmapData(40, 5400);
                     jpgSource.draw(zoomContainer_mc.mainContainer_mc);
                     var jpgEncoder:JPGEncoder = new JPGEncoder();
                     var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);
                     var byteArrayAsString:String = Base64.encodeByteArray(jpgStream);
                     // set data to send
                     variables = new URLVariables();
                     
                     variables.format = "jpg";
                     //variables.action = options.action;
                     variables.fileName = userID+"_part_"+currentTileIndex+".jpg";
                     variables.userID = userID;
                     trace("Compass: "+byteArrayAsString);
                     variables.image = byteArrayAsString;
                     
                     loader.dataFormat = URLLoaderDataFormat.VARIABLES;
                     
                     request.data = variables;
                     loader.load(request);