|
|||
|
I am having trouble with the getUrl function. This is my code;
Code:
var inet = new Inet;
if(inet.isInetConnected()){
trace("we are connected to the net");
inet.onGetUrl = on_geturl;
if(inet.getUrl("http://www.cell-media.com/test.txt/", "C:\\Program Files\\Common Files\\ROMS\\test.txt\\")){
trace("jolly good, we got the url");
}else{
trace("poor show what, no url!");
}
geturl_action = "versionNum";
}else{
trace("no net connection!");
}
function on_geturl(type, msg){
trace("on_geturl() msg = " + msg);
if(msg){
}
}
"we are connected to the net poor show what, no url!" Which is to say that the internet connection is detected but the getUrl method returns false, without triggering the on_geturl() function. Your help would be greatly apreciated. Jon |
|
|||
|
The onGetUrl event is used to check whether there is any problem when downloading the remote file, and how many bytes has been downloaded. If the remote file does not exist, the getUrl method just returns false without firing the onGetUrl event.
|
|
|||
|
I was about to whinge but then i checked what i actually posted. As written, your right, that code has little chance of working. I tried a lot of variations in the course of trying to get it to work before i posted and it seems I posted the wrong one as an example. The getUrl line should be;
Code:
if(inet.getUrl("http://www.cell-media.com/test.txt", "C:\\Program Files\\Common Files\\ROMS\\test.txt")){
|
|
|||
|
Well, I'm learning a bit about the getUrl function but I still dont understand it all.
The onGetUrl function fires before the whole file is downloaded. What should I do to download a file and only do the next function once the file is downloaded? |
|
|||
|
The "getUrl" method works like:
Code:
function getUrl(url, filename) {
if (!open_remote_file(url)) return false;
while ((bytes = read_remote_file(url)) > 0) {
if (error) {
onGetUrl(error);
return false;
}
onGetUrl(bytes);
write_data(filename, bytes);
}
return true;
}
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|