Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-22-2007, 12:50 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,000
Default Creating zip files by using SWFKit Pro

By using the LiteZip, you can create zip files in swfkit pro.

First, add the LiteZip.dll into the "Resources" panel in swfkit pro

Second, in the "initialize" script, define the functions in LiteZip.dll
Code:
var LiteZip = getAdditionalFile("LiteZip.dll");
// creates a new zip file
// 	handle - returns a handle to the newly created zip file.
//		With the handle we can add files into the zip file
//	filename - the name of the zip file to create
//	password - password for the zip file to create
dllimport LiteZip stdcall long ZipCreateFileA(long* handle, String filename, String password) as zipCreate;
// closes a zip file
dllimport LiteZip stdcall long ZipClose(long handle) as zipClose;
// adds a file into the zip file
//	handle - the handle of the created zip file
//	nameInZip - the name of the file after added into the zip file
//	fileToAdd - the path name of a disk file to add
dllimport LiteZip stdcall long ZipAddFileA(long handle, String nameInZip, String fileToAdd) as zipAddFile;
// adds a folder to a zip file
dllimport LiteZip stdcall long ZipAddFolderA(long handle, String folderName) as zipAddFolder; 
// adds a folder on disk into a zip file
//	handle - the handle of the zip file to operate
//	dirName - name of the directory on disk
//	offset - from where the sub string of a file name on disk will be
//		the name in the zip file. For example, to add the directory
//		"c:\flash\test", in which there is a file "sample.pdf", if 
//		offset is length of the string "c:\flash\test\", the "sample.pdf" 
//		in the zip file will still be "sample.pdf"; however, if the
//		offset is length of string "c:\flash\", the name of "sample.pdf" in 
//		zip file will be "test\sample.pdf", that is, it is in the "test"
//		folder. Say the full path name of a disk file is strFullName, its
//		name in zip is strZipName, then
//		
//		strZipName = strFullName.substring(offset);
dllimport LiteZip stdcall long ZipAddDirA(long handle, String dirName, long offset) as zipAddDir;
Third, call the functions in ffish script to create a zip file
Code:
// creates a new zip file to get a handle
var handle = new Object;
handle.value = 0;
zipCreate(handle, "c:\\flash\\1.zip", "");
// adds files
zipAddFile(handle.value, "hi.txt", "c:\\flash\\hi.txt");
zipAddFile(handle.value, "myfiles\\readme.txt", "c:\\flash\\1.txt");
// adds an empty folder
zipAddFolder(handle.value, "newfolder");
// adds files in a directory
zipAddDir(handle.value, "c:\\flash\\test", "c:\\flash\\".length);
// closes and saves the zip file
zipClose(handle.value);
The attached file is the "LiteZip.dll".
Reply With Quote
  #2 (permalink)  
Old 08-24-2007, 01:14 PM
Member
 
Join Date: May 2004
Posts: 72
Default Re: Creating zip files by using SWFKit Pro

This looks great and will be a really helpful addition to pack files from my programs. Thanks for coming up with this solution.

I have one question - the above code looks like it saves the file to the C: drive. I haven't tried it yet, but will do so later on. Can I just check - is there a way to make sure the user can choose where to save the .zip file instead?

I ask this because on a corporate network most users will not have the ability to save to their C: drive.
__________________
Reply With Quote
  #3 (permalink)  
Old 08-25-2007, 09:13 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,000
Default Re: Creating zip files by using SWFKit Pro

Sure, it can be anywhere on disk.
Reply With Quote
  #4 (permalink)  
Old 08-26-2007, 01:29 AM
Member
 
Join Date: May 2004
Posts: 72
Default Re: Creating zip files by using SWFKit Pro

Ah - sorry - I wasn't quite clear enough with this request.

It looks like this addition automatically saves files to the C: drive of the user's computer when then .zip file is created.

Instead, is it possible to have some files stored in the resources section of SWFKit and a new file generated which are then all packaged up as a .zip and saved in the location the user chooses. This is what I need!
__________________
Reply With Quote
  #5 (permalink)  
Old 08-26-2007, 10:59 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,000
Default Re: Creating zip files by using SWFKit Pro

Sure, for example:

Code:
var filename = Dialogs.fileOpen("Zip files(*.zip)|*.zip|", "zip");
if (filename) {
  ...
  zipCreateFile(handle, filename, "");
  ...
}
Reply With Quote
  #6 (permalink)  
Old 10-09-2007, 06:41 PM
Member
 
Join Date: May 2004
Posts: 72
Default Re: Creating zip files by using SWFKit Pro

Hi again.

I still cannot quite get this to work.

I have a .zip file with lots of files in it already where I want to add an additional file. I could either recreate the entire .zip file or I could just add a file to the existing one.


Code:
// get 3 files from the resources panel
var savedFile1 = new File(getAdditionalFile("example.swf"));
var savedFile2 = new File(getAdditionalFile("example.js"));
var savedFile3 = new File(getAdditionalFile("example.html"));

// fileLoad or Save?
// In the examples it shows fileOpen, but that doesn't make sense
var filename = Dialogs.fileSave("Zip files(*.zip)|*.zip|", "zip");

if (filename) {

// Generating .zip file
// creates a new zip file to get a handle

  var handle = new Object;
	handle.value = 0;

// create zip and add files
	zipCreateFile(handle.value, filename, savedFile1);
    zipAddFile(handle.value, filename, savedFile2);	
    zipAddFile(handle.value, filename, savedFile3);

	// closes and saves the zip file
	zipClose(handle.value); 
}
I cannot get this to work though. ???

What would be even better would be to have a standard .zip file from the resources panel that I just add two files to and then create the new .zip file.
__________________
Reply With Quote
  #7 (permalink)  
Old 10-09-2007, 11:56 PM
Member
 
Join Date: May 2004
Posts: 72
Default Re: Creating zip files by using SWFKit Pro

I think I've found the errors I've been making - I've now successfully been able to generate a .zip file using the following code:

Code:
// get the name for the saved .zip file
var filename = Dialogs.fileSave("Zip files(*.zip)|*.zip|", "zip");
if (filename) {

	// Generating .zip file
	// creates a new zip file to get a handle
  var handle = new Object;
	handle.value = 0;
	zipCreate(handle, filename, "");

	// grab a file from the resources panel
	var file1 = getAdditionalFile("example.swf");

	//	zipAddFile
	// adds files
	zipAddFile(handle.value, filename, file1);
	
	// closes and saves the zip file
  zipClose(handle.value); 
}
What I'm still stuck on is how to have an existing .zip file in the resources section and then add two additional files to it. Any ideas?
__________________
Reply With Quote
  #8 (permalink)  
Old 03-31-2008, 05:04 PM
Junior Member
 
Join Date: Aug 2006
Location: Germany
Posts: 27
Send a message via MSN to snakemedia Send a message via Yahoo to snakemedia
Default Re: Creating zip files by using SWFKit Pro

Quote:
Originally Posted by AndyField
I think I've found the errors I've been making - I've now successfully been able to generate a .zip file using the following code:

Code:
// get the name for the saved .zip file
var filename = Dialogs.fileSave("Zip files(*.zip)|*.zip|", "zip");
if (filename) {

	// Generating .zip file
	// creates a new zip file to get a handle
  var handle = new Object;
	handle.value = 0;
	zipCreate(handle, filename, "");

	// grab a file from the resources panel
	var file1 = getAdditionalFile("example.swf");

	//	zipAddFile
	// adds files
	zipAddFile(handle.value, filename, file1);
	
	// closes and saves the zip file
  zipClose(handle.value); 
}
What I'm still stuck on is how to have an existing .zip file in the resources section and then add two additional files to it. Any ideas?
Good Idea! I want to build a sample package installer like Mac OS X *.dmg, Linux *.deb and *.rpm and more.. How do i work with unknown zipped files?? . example Flex OS: *.fxpi. It works?

Thanks for tips . Bye SnakeMedia
__________________
Sorry I am deaf! I have problem with eys... Thanks!
Reply With Quote
  #9 (permalink)  
Old 10-24-2008, 03:25 PM
Junior Member
 
Join Date: Oct 2008
Posts: 7
Default Re: Creating zip files by using SWFKit Pro

I lost whole day to figure out something with LiteZip.dll. As a result my app creates zip and then it just gives an error message. I think, something gets wrong when adding files to the zip.
I'd very thankful to someone who can tell what is the easiest way to zip files or at least who could give a simple tutorial how to create a dll and call functions of that dll from flash. I've installed VisualBasic. Which programming language is best for creating ActiveX dll's? Or all of them are the same?
And one more question. Can SWFKit call only ActiveX dll functions or it is also possible to import other dll files and call their functions? As far as I understand dll and Activex dll files are different.
I hope someone will ray some light on this issue.
P.S. it's possible to find any dll files on net and download them, but they don't give any information on available function and variables in dll files, is it possible to get those variables and informations from a dll?

Thank you,

Anar Selimhanov
selimhanov@gmail.com
Reply With Quote
  #10 (permalink)  
Old 10-27-2008, 07:36 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,000
Default Re: Creating zip files by using SWFKit Pro

LiteZip is a normal dll, not an activex dll. Do you mean that you are trying to call it from VB? Perhaps you haven't import it correctly into VB?

If you don't have document of a dll, it would be very difficult to know how to use it.
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:12 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.