Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-23-2007, 05:40 PM
Junior Member
 
Join Date: Dec 2006
Posts: 26
Default downlod , resume file

hi

is possible to resume a big file if the connection break off ?

fly
Reply With Quote
  #2 (permalink)  
Old 01-25-2007, 08:42 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:downlod , resume file

This feature is not available at present. However, we may add it in the future version.
Reply With Quote
  #3 (permalink)  
Old 05-27-2007, 10:07 AM
Junior Member
 
Join Date: Dec 2006
Posts: 26
Default Re:downlod , resume file

hi

I have to develop and application with this feature , is there any new about this feature ?
when do you think to add this feature ?

thanks
Reply With Quote
  #4 (permalink)  
Old 05-28-2007, 05:39 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:downlod , resume file

We are making a http downloader activex component, and it will soon be ready.
Reply With Quote
  #5 (permalink)  
Old 05-29-2007, 10:23 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:downlod , resume file

The Downloader.dll has been finished, which is included in the attached sample. It contains two objects

The first one is ZHttpDownloader, to create it, use the following code
Code:
var downloader = new ActiveXObject("SWFKit.ZHttpDownloader");
It has two methods shown as follows
1) Download(url, filename, startPos, length, downloadAnyway)
This function will download a remote file specified by [url] in a new thread so that it will not block the main program. It supports both HTTP and FTP files. However, it does not support to resume ftp files. The [filename] parameter specifies the local file name to save the downloaded data. The [startPos] specifies the start position of the remote file to download. For a ftp file, or a http file does not support to resume, this parameter can only be zero. The [length] parameter specifies the length of data to download. If it is zero, the entire remote file will be downloaded. If [startPos] is not set to zero, and the remote file does not support to resume, and [downloadAnyway] is set to true, the function will download from the beginning of the remote file, and will download the entire remote file.

If startPos is not zero, and the length of the output file [filename] is less than startPos, download will fail. In that case, you will have to use the SetFileSize method of the ZFileUtilities object to set the size of the output file.

2) Stop()
This function is used to stop the download started by the Download function

The object has one property [BytesDownloaded], which specifies the number of bytes that have been downloaded by the Download function.

The object has the following three events
1) OnFail
If the download has failed, this event will be triggered

2) OnComplete

3) OnProgress(size)
Triggered when the Download function have got some data, the size is the number of bytes received after the previous OnProgress event. By handling this event, you can display the download progress.

Another object is ZFileUtilities, it can be created by the following code
Code:
var fu = new ActiveXObject("SWFKit.ZFileUtilities");
It has only one method

SetFileSize(filename, length)
[filename] is the name of the local file to set its size
[length] is the size of the file to set. If the file does not exist, it will be created, and be filled up to [length]
Reply With Quote
  #6 (permalink)  
Old 05-29-2007, 10:53 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:downlod , resume file

You can also use this component to download a file by using multiple threads - use different thread to download different part of the remote file. Before you download the remote file, you must first create a local file with the same size as the remote file so that the different threads can write to different parts of the local file. However, the Downloader component uses wininet.dll to download files, which restricts the number of concurrent connections to a server. For Http 1.1, the default number of allowed concurrent connections is 2. Therefore, please do not use more than two threads to download a file. Otherwise, the extra threads will be blocked until the first two threads have finished downloading their parts.

The following ffish script code shows how to download a file using two threads
Code:
var downloader = new ActiveXObject("SWFKit.ZHttpDownloader");
var downloader1 = new ActiveXObject("SWFKit.ZHttpDownloader");

downloader.onFail = downloader1.onFail = function (msg)
{
trace(msg);
}

downloader.onComplete = downloader1.onComplete = function ()
{
trace("finished!");
}

downloader.onProgress = function(iSize) {
trace(iSize);
}

var filename = "c:\\flash\\setup.exe";
var url = "http://www.swfkit.com/download/swfkit/frobjsetup.exe";

// get the size of the remote file
var inet = new Inet;
var size = inet.getHttpFileSize(url);

var part = Math.floor(size / 2);


var fu = new ActiveXObject("SWFKit.ZFileUtilities");
fu.setFileSize(filename, size);

// download use two threads
downloader.download(url, filename, 0, part, false);
downloader1.download(url, filename, part, 0, false);
Reply With Quote
  #7 (permalink)  
Old 05-29-2007, 12:41 PM
Member
 
Join Date: May 2007
Posts: 53
Default Re:downlod , resume file

I wonder, if there is a way to pack this lib into my myapp.exe in SWFKit?
( As in mdm zinc: mdm.Application.Library.extractAllToDir(extractDir :String):Void )
__________________
#define true false //happy debugging, friends
Reply With Quote
  #8 (permalink)  
Old 05-29-2007, 01:12 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:downlod , resume file

http://www.swfkit.com/swfkit/doc/manual/node28.html

The attached sample "ZDownloader.dll" uses the "register" method to register the Downloader ActiveX component - first copy it into the system folder, and then register it. However, in this way, the exe file will require the administrator privilege. Using the setup file to register the dll is recommended.
Reply With Quote
  #9 (permalink)  
Old 05-29-2007, 01:30 PM
Member
 
Join Date: May 2007
Posts: 53
Default Re:downlod , resume file

Yes, i read that manual before. Anyway, i cant include the .dll in the compiled file.
Actually, I don't use installer.
I add the file in the resource pannel and compile the app. But the size of the app does not changes..
__________________
#define true false //happy debugging, friends
Reply With Quote
  #10 (permalink)  
Old 05-29-2007, 02:25 PM
Member
 
Join Date: May 2007
Posts: 53
Default Re:downlod , resume file

Sorry for that dumb question.
Now, i've used my magic skills and forced it to work.
Now, its all fine -)
Thx!
__________________
#define true false //happy debugging, friends
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 04:04 AM.


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