|
|||
|
I need to download files from network in my project.
i used: inet.getUrl(distr_url, TMP_distrib_file_path); ExternalInterface.call('MyGetUrl', distr_url, TMP_distrib_file_path); fscommand('FFish_Eval', 'MyGetUrl("'+distr_url+'", "'+TMP_distrib_file_path+'")'); In any case, the app stopps performing any action while the file is not downloaded. And another problem. When i use String(ExternalInterface.call('fileSize', appPath)), and rin my app from local disk drive, all works properly. But u run the app from a network shared folder it causes crytical error and my app closes immediately. Now, i've found a solution: to rewrite this code http://msdn2.microsoft.com/en-us/library/aa384104.aspx in SWFKit :-))) But, maybe you could show me a better way? Thanks in advance.
__________________
#define true false //happy debugging, friends |
|
|||
|
The File object in SWFKit does not work with a network shared file. Please use the following function to get the size of a shared file.
Code:
dllimport "kernel32.dll" stdcall long CreateFileA(String, long, long,
pointer, long, long, long) as win32_createFile;
dllimport "kernel32.dll" stdcall long GetFileSize(long, pointer) as win32_getFileSize;
dllimport "kernel32.dll" stdcall Boolean CloseHandle(long) as win32_closeHandle;
function myGetFileSize(filename) {
if (filename.indexOf("\\\\") == 0) {
// a newwork shared file
var handle = win32_createFile(filename, 0x80000000/*GENERIC_READ*/,
0x00000001/*FILE_SHARE_READ*/, null, 3/*OPEN_EXISTING*/,
0x00000080/*FILE_ATTRIBUTE_NORMAL*/, 0);
if (handle != 0xFFFFFFFF) {
var size = win32_getFileSize(handle, null);
win32_closeHandle(handle);
return size;
}
return -1;
} else {
var f = new File(filename);
return f.size;
}
}
|
|
|||
|
The Inet object runs in block mode. That is to say, it will block the main window. To avoid the problem, you will have to give the main window chances to handle messages, for example, mouse clicks, repaint, etc, during downloading. That can be done by calling the processMsg method in the "onGetUrl" event handler.
Code:
var inet = new Inet;
inet.onGetUrl = function (type, msg) {
if (!processMsg())
return false;
return true;
}
inet.getUrl("...", "...");
|
|
|||
|
The problem appearing when the inet.getUrl() blocks my app remains on some computers. I cant find the reason, but the problem exists on 2 computers from 10 tested. :-((
__________________
#define true false //happy debugging, friends |
|
|||
|
Because the file downloading does not run in a separate thread, it is very hard to make the program 100% smooth, especially on a computer with a narrow band internet connection. If you think it is unacceptable, please wait for our http downloader activex component. But it also has its disadvantage that it supports only http files.
|
|
|||
|
Well, its quite needed feature. It is used, mainly, for auto-downloading newer versions of our app. And when the app hungs up for 1-15 mins - its, really, unacceptable.
What about that ActiveX component?
__________________
#define true false //happy debugging, friends |
|
|||
|
http://www.swfkit.com/forum/thread_1_1772.html
It also supports FTP files, but it cannot resume a FTP download. |
|
|||
![]() my code var inet = new Inet; var filesize = inet.getHttpFileSize("http://www.baidu.com/img/baidu_logo.gif"); inet.onGetUrl = function(type, msg){ percent = Math.ceil((msg/filesize)*100); FlashPlayer.targetGotoFrame("bar", percent); if (!processMsg())return false; return true; } inet.getUrl("http://www.baidu.com/img/baidu_logo.gif", getAppDir()+"baidu_logo.gif"); who can tell my, what's happen code still can't work when i run app, the main win is block i have use processMsg(); |
|
|||
|
Quote:
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|