2

My requirement is to save a bunch of files (more than 500) in a single zip file locally using FileReference. I am using ASZip to zip the files. Now the problem is if the number of files are more, then I am not even getting Save as dialog box.

I have tried different combinations of data to see whether it is number of files or file size limitation, but it looks like the script automatically stops (irrespective of number of files), if it can't give me the output within a minute.

This is the code that I am using

   //*****test code
var myZip:ASZip = new ASZip (CompressionMethod.GZIP);
var myByteArray:ByteArray = new ByteArray();var pdfFile:PDF;
var newPage:Page;
var printPage:BorderContainer;
for (var i:int=0;i<330;i++)
{
    printPage = new BorderContainer();
    printPage.visible = false;
    printPage.x=0;
    printPage.y=0;
    printPage.includeInLayout = false;
    printPage.width = 816+10;
    printPage.height = 1056+23;
    this.addElement(printPage);
    pdfFile = new PDF(Orientation.PORTRAIT, Unit.INCHES, Size.A3 );
    pdfFile.setDisplayMode( Display.FULL_PAGE,Layout.SINGLE_PAGE  );
    newPage = new Page ( Orientation.PORTRAIT,Unit.INCHES,new Size([816+10,1056+10],"MyFavoriteSize",[8.5+10,11+10],[816/0.125,1056/0.218]));
    pdfFile.addPage(newPage);
    pdfFile.beginFill(new RGBColor(0xFFFFFF));
    pdfFile.textStyle(new RGBColor(0x000000));
    pdfFile.addImage(printPage,null,-0.5,-0.5,8.5+4,11.5+4);
    myByteArray = pdfFile.save(org.alivepdf.saving.Method.LOCAL);
    myZip.addFile(myByteArray,i + ".pdf");
}

Can you please let me know what can be done to fix this issue?

Thanks, Satish.

satish
  • 41
  • 3
  • I am using the following code to save the file var file:FileReference = new FileReference(); var myZipFile:ByteArray = myZip.saveZIP(org.aszip.saving.Method.LOCAL); file.save(myZipFile, "testzip.zip"); – satish Aug 14 '15 at 02:49
  • It looks like scriptTimeLimit property is causing this. By default it is set to 60 sec, because of which, my script is timing out after 1 minute. Is there anyway to overcome this issue? – satish Aug 14 '15 at 05:05
  • create a separate worker swf to do the processing. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Worker.html – BadFeelingAboutThis Aug 14 '15 at 05:13
  • Looks like a timeout issue. Is your app idling the whole time? If so process everything in batches instead. – BotMaster Aug 14 '15 at 13:57
  • Thanks for your reply. problem is i can't process it in batches. App is idle while the process is running. Is there any way that we can change this default timeout value. – satish Aug 14 '15 at 16:38
  • Do you have any examples on how Worker swf can be used? – satish Aug 14 '15 at 16:39

0 Answers0