1 Reply Latest reply on May 21, 2009 2:45 PM by injpix

    [urgent] Flex fileRef.download problems.

    J Krav

      Hi all,


      I am having trouble figuring out what to do here.

      I am sending images to coldfusion, and using cfzip to create a zip of the images for download.

      I am using fileRef.download to download the zip to the user's computer in actionscript.

      The problem is that flex will let the user download the zip before it is finished compiling.

      So if there are 68 images in the zip on the webserver, depending on how fast you select the save location you could only get 42...or 29....etc.


      I tried putting the download function in the return handler for the coldfusion remote object, but fileRef.download must be executed by a mouse-click for security reasons.

      Here is the click handler for the "download images" button.

      Here is the code below:


      public function clickHandler1(event:Event):void
                      h = 0;
                      randomFileNum = Math.round(Math.random()*(99999-11111))+11111;
                      var t:int;
                      for (t = 0; t < HiResImageCollection.length; t++)
                      image1 = HiResImageCollection[h];
                      imgStyleNumber = StyleNumberCollection[h]+ "_" + ColorCollection[h] + pORiCollection[h] ;
                      h = h + 1;
                       downloadURL.url = "http://costmesa-svr-17/HIB/ImagesTemp/DownloadedImages" + randomFileNum + ".zip" + "?" + Math.random();

                       fileRef.download(downloadURL, 'DownloadedImages' + randomFileNum + '.zip');




      Thank you for your much needed help.