Forum Topic: Wierd text loading problem?

(140 views • 9 replies)

This topic is 1 page long.

<< < > >>
Questioning

B0UNC3

Reply To Post Reply & Quote

Posted at: 9/19/09 07:25 AM

B0UNC3 DARK LEVEL 06

Sign-Up: 01/04/05

Posts: 1,537

Hi thar Flash forum, I've used Flash CS4 for 3 hours or so total (I'm the noobiest noob ever) and with the help of some guides I figured out how to make my Flash website read text from a text document.

It all works but the text is displayed very wierd and I have no idea of where to even begin troubleshooting. None of the guides I've found covers this problem either so I'm pretty much clueless.

This is what the code to read the text looks like (AS2):

var content:LoadVars = new LoadVars();
lvs.onLoad = function(success:Boolean):Void  {
	if (success) {
		home_txt.text = lvls.varName;
	} else {
		home_txt.text = "Unable to load external file.";
	}
};
content.load("home.txt");

This is what it should look like:

Hi and welcome, this is a test.

But this is what comes out:

Hi%20and%20welcome%2C%20this%20is%20a%20test%2E%0D%0A=
I did search before asking, but I don't even know what to call the problem so that makes searching abit more difficult.

Did I just simply make a noob mistake and miss something annoyingly obvious to everyone else?


None

MouthWash82

Reply To Post Reply & Quote

Posted at: 9/19/09 07:36 AM

MouthWash82 NEUTRAL LEVEL 01

Sign-Up: 09/19/09

Posts: 4

%20 is a space character.
It would probably make more sense not to loadVars, but to load in a text file to a string the read from that.

var loader:URLLoader = new URLLoader(new URLRequest("http://abc.com/files/123.txt"));
loader.load();
var string:String = loader.data;

That's AS3 though so that doesn't help.


None

dor-the-flasher

Reply To Post Reply & Quote

Posted at: 9/19/09 08:33 AM

dor-the-flasher NEUTRAL LEVEL 12

Sign-Up: 12/06/03

Posts: 14

can you please tell us whats the properties of the text box thats displaying the text?

"You can just hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters." Eric Cartman


None

Zielak

Reply To Post Reply & Quote

Posted at: 9/19/09 08:35 AM

Zielak FAB LEVEL 17

Sign-Up: 09/21/05

Posts: 865

First, check if your text file was written with UTF-8 character encoding.
If you're using notepad from windows:
open the file, save as, the bottom field in pop-up window should be called "Encoding", change it to UTF-8 first. If this doesn't work change to any other.

Or find a function online that replaces some characters into ones that you want. Like a function that will change "%20" into " " (a blank space). I don't actually have a time to write it for you so good luck with searching.


None

B0UNC3

Reply To Post Reply & Quote

Posted at: 9/19/09 09:03 AM

B0UNC3 DARK LEVEL 06

Sign-Up: 01/04/05

Posts: 1,537

Would it be more convenient if I changed around the code from AS2 to AS3? Would this problem be solved then?

The site doesn't contain all that much code so I could definetly do it.

At 9/19/09 08:33 AM, dor-the-flasher wrote: can you please tell us whats the properties of the text box thats displaying the text?

Name: home_txt
Dynamic text
Multi line
Thats all the properties for it. Is that enough?:P


None

Zielak

Reply To Post Reply & Quote

Posted at: 9/19/09 09:16 AM

Zielak FAB LEVEL 17

Sign-Up: 09/21/05

Posts: 865

I thought you were already working with AS3...


None

dor-the-flasher

Reply To Post Reply & Quote

Posted at: 9/19/09 09:26 AM

dor-the-flasher NEUTRAL LEVEL 12

Sign-Up: 12/06/03

Posts: 14

is the "Rendar as HTML" on? i dont know if it can cuase this to happnd but it might
if it is turn it off
and do chack the coding of your txt file
im using the same code in some websites i made and it works with no promlams and im using AS2

"You can just hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters." Eric Cartman


None

B0UNC3

Reply To Post Reply & Quote

Posted at: 9/19/09 11:00 AM

B0UNC3 DARK LEVEL 06

Sign-Up: 01/04/05

Posts: 1,537

At 9/19/09 09:26 AM, dor-the-flasher wrote: is the "Rendar as HTML" on? i dont know if it can cuase this to happnd but it might
if it is turn it off

Makes no difference.

and do chack the coding of your txt file

My textfile is just plain text, no code whatsoever (Followed 3-4 guides to the point) but I still don't get the result I "should".

im using the same code in some websites i made and it works with no promlams and im using AS2

I had a quick test converting all the code to AS3 (No compiler errors, yay!) but then came to a screeching halt getting the text to load at all (DOH).

Sucks to be a noob >:(


Shouting

Halosheep

Reply To Post Reply & Quote

Posted at: 9/19/09 01:19 PM

Halosheep NEUTRAL LEVEL 05

Sign-Up: 04/09/09

Posts: 333

Pigs just flew and shat bicks on my head.
I can't believe I just saw a mod call himself a "nooby noob" and ask for help.

"If everyone in the world did things 75% right all the time, the world would be much better than it is right now, so i demand you change this C to an A+!" - Calvin and Hobbes


None

B0UNC3

Reply To Post Reply & Quote

Posted at: 9/19/09 06:49 PM

B0UNC3 DARK LEVEL 06

Sign-Up: 01/04/05

Posts: 1,537

At 9/19/09 01:19 PM, Halosheep wrote: Pigs just flew and shat bicks on my head.
I can't believe I just saw a mod call himself a "nooby noob" and ask for help.

Figured i'd be the first.

Anyone else?=(


All times are Eastern Standard Time (GMT -5) | Current Time: 08:55 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!