Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-12-2008, 02:31 AM
jon jon is offline
Junior Member
 
Join Date: Sep 2007
Posts: 25
Default inet.getUrl(url, localname) problem

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){

	}
}
this traces;

"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

Reply With Quote
  #2 (permalink)  
Old 02-12-2008, 07:27 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: inet.getUrl(url, localname) problem

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.
Reply With Quote
  #3 (permalink)  
Old 02-12-2008, 10:59 PM
jon jon is offline
Junior Member
 
Join Date: Sep 2007
Posts: 25
Default Re: inet.getUrl(url, localname) problem

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")){
that trailing slash does make a difference. This file does exist, the program behaves the same with this syntax.
Reply With Quote
  #4 (permalink)  
Old 02-13-2008, 11:26 PM
jon jon is offline
Junior Member
 
Join Date: Sep 2007
Posts: 25
Default Re: inet.getUrl(url, localname) problem

Sorry to harp on about this but its very inconvenient for me. As far as I can tell the getUrl function does not behave as expected.

Here is a sample file.
Reply With Quote
  #5 (permalink)  
Old 02-15-2008, 03:06 AM
jon jon is offline
Junior Member
 
Join Date: Sep 2007
Posts: 25
Default Re: inet.getUrl(url, localname) problem

The problem was that the directory i was downloading the file into did not exist. I assumed it would be created automatically but i was wrong.
Reply With Quote
  #6 (permalink)  
Old 02-15-2008, 06:56 AM
jon jon is offline
Junior Member
 
Join Date: Sep 2007
Posts: 25
Default Re: inet.getUrl(url, localname) problem

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?
Reply With Quote
  #7 (permalink)  
Old 02-18-2008, 06:28 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: inet.getUrl(url, localname) problem

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;
}
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:59 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.