Be a Supporter!

loading info from a txt

  • 398 Views
  • 13 Replies
New Topic Respond to this Topic
Spectacle
Spectacle
  • Member since: Apr. 10, 2006
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
loading info from a txt 2007-06-23 16:12:33 Reply

how do I get flash to display information from a text file?


f

BBS Signature
gorman2001
gorman2001
  • Member since: Aug. 18, 2002
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to loading info from a txt 2007-06-23 16:18:45 Reply

use the loadVar function.


website :: hugostonge.com
my job :: we+are

Spectacle
Spectacle
  • Member since: Apr. 10, 2006
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to loading info from a txt 2007-06-23 16:35:33 Reply

I did this:
onEnterFrame = function() {
mydata = load("http://localhost/game.txt")
trace(mydata);
}
but something's not working for some reason


f

BBS Signature
Spectacle
Spectacle
  • Member since: Apr. 10, 2006
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to loading info from a txt 2007-06-23 16:37:57 Reply

At 6/23/07 04:35 PM, Spectacle wrote: I did this:
onEnterFrame = function() {
mydata = load("http://localhost/game.txt")
trace(mydata);
}
but something's not working for some reason

oh and the output is "undefined" and in the text file is just numbers.


f

BBS Signature
GustTheASGuy
GustTheASGuy
  • Member since: Nov. 2, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to loading info from a txt 2007-06-23 16:41:43 Reply

There is no 'load' function. To read a file you need to use the LoadVars.onData event.


BBS Signature
Spectacle
Spectacle
  • Member since: Apr. 10, 2006
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to loading info from a txt 2007-06-23 16:47:09 Reply

ok I've fixed that now, but it doesn't seem to do that well

the output comes out as "201%2E25%2C219%2E25=" and this is what's in the text file "201.25,219.25"
is there a way to display it exactly as it is in the text file? this is the script now:
mydata = new LoadVars();
onEnterFrame = function() {
mydata.load("http://localhost/game.txt")
trace(mydata);
}


f

BBS Signature
GustTheASGuy
GustTheASGuy
  • Member since: Nov. 2, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to loading info from a txt 2007-06-23 17:22:20 Reply

Again, onData.


BBS Signature
Spectacle
Spectacle
  • Member since: Apr. 10, 2006
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to loading info from a txt 2007-06-23 17:32:22 Reply

At 6/23/07 05:22 PM, GustTheASGuy wrote: Again, onData.

onData is basically used to check when the data has finished loading from a source or when there is an error downloading from a source.
onData isn't required for the information to be recieved. I've recieved the information the only problem now is that it converts the full stops and commas into something else.


f

BBS Signature
GustTheASGuy
GustTheASGuy
  • Member since: Nov. 2, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to loading info from a txt 2007-06-23 18:16:39 Reply

var mydata = new LoadVars();
mydata.onData = function (data) {
trace (data);
};

Give me a break.


BBS Signature
Spectacle
Spectacle
  • Member since: Apr. 10, 2006
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to loading info from a txt 2007-06-23 22:35:43 Reply

At 6/23/07 06:16 PM, GustTheASGuy wrote: var mydata = new LoadVars();
mydata.onData = function (data) {
trace (data);
};

Give me a break.

I can't see how that would work at all.


f

BBS Signature
ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to loading info from a txt 2007-06-23 23:40:43 Reply

Then you probably have no idea what onData is/does, look it up. Did you even try what he said?


AS: Main

Don't read this sentence.

authorblues
authorblues
  • Member since: Jun. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to loading info from a txt 2007-06-23 23:42:12 Reply

At 6/23/07 10:35 PM, Spectacle wrote: I can't see how that would work at all.

thats because youre a bratty kid who refuses to accept help from knowledgable people.

var lv:LoadVars = new LoadVars();
lv.onData = function():Void{
for (var i:String in this) trace(i + ": " + this[i]);
};

lv.sendAndLoad('/path/to/text/file.txt', lv);


BBS Signature
Spectacle
Spectacle
  • Member since: Apr. 10, 2006
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to loading info from a txt 2007-06-24 00:17:57 Reply

At 6/23/07 11:42 PM, authorblues wrote:
At 6/23/07 10:35 PM, Spectacle wrote: I can't see how that would work at all.
thats because youre a bratty kid who refuses to accept help from knowledgable people.

yeah, you're right I was actually just being stupid and moody. I was getting annoyed the flash wasn't working and it turns out that the script he gave me did work and I had just made a mistake.

Sorry to GustTheASGuy for getting annoyed and thanks for the help.


f

BBS Signature
Spectacle
Spectacle
  • Member since: Apr. 10, 2006
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to loading info from a txt 2007-06-25 17:58:19 Reply

what's the difference between putting the load part this way round:
mydata.load("http://localhost/conv.txt")
mydata.onData = function (data) {
//script
}
and putting it this way round:
mydata.onData = function (data) {
//script
}
mydata.load("http://localhost/conv.txt")


f

BBS Signature