PDA

View Full Version : loading text with AS



morse
May 11th, 2003, 02:36 PM
Is there any way to make line breaks when you load text into a dynamic text box, other than using html? And if not, could someone give me an example of how to do it using html?

Jubba
May 11th, 2003, 02:50 PM
\n = new line

\r = carriage return


just put them where you want them. Should work.

morse
May 11th, 2003, 02:58 PM
can I do this?:

quote = new Array("'' Tastes Like Burning ''\n - Ralph")

and then load text into a box from the array? I mean, I know I can load the text from the array, but is that up there legal?

Jubba
May 11th, 2003, 03:00 PM
yeah, what exactly are you trying to do?

quote = "Tastes Like Burning \n - Ralph"

just include the \n right in the string. and be careful its \ not /

sanman918
May 11th, 2003, 03:02 PM
Hey, I'm having the same problem. I have a text box loaded dynamically and I have it in HTML format but when I put things like <b>News</b> in my notepad file they don't show up when i publish. Is there anyway that I don't make it HTML and use the /n and /r commands. Because when I put /n it actually shows up when I publish

morse
May 11th, 2003, 03:02 PM
Oh I see. I'm making a random quotes thinger.

morse
May 11th, 2003, 03:03 PM
Oy hey it does work! Thanks a trillian gazillian Jubba!

sanman918
May 11th, 2003, 03:03 PM
i mean i use \n and it still doesn't work...that was a typo in the post

sanman918
May 11th, 2003, 03:03 PM
i still need help :(

mlk
May 11th, 2003, 04:02 PM
maybe if you post the fla we can help, or post some code, it's either the way you made your text file or your as syntax...

sanman918
May 11th, 2003, 11:38 PM
i got everything to work now I just can't get things to be bold or what not. this is what i have in my firstframe

loadText = new loadVars();
loadText.load("news.txt");
// creating the loadVarsText function
loadText.onLoad = function() {
_root.text.scroller.html = true;
_root.text.scroller.htmlText = this.newstext;
};


and this is what I have in my notpad file

newstext=

<p><b>Layout - </b>Posted by Sanman</p>
<p>This is the news page.</p>

and the word layout won't show up.?

sanman918
May 11th, 2003, 11:39 PM
"newstext=

<p><b>Layout - </b>Posted by Sanman</p>
<p>This is the news page.<p>"

I would like to get rid of the HTML part and just use the \n and \r

Elios
May 12th, 2003, 05:56 AM
Well, then what you're looking for is the url encode method. You can't use escape characters in the text file. Where you would have used "\n", use "%0d", and where you would have used "\r", use "%0a". Other useful codes are: "%09" (tab) and "%20" (space). Anyway, the problem is that Flash doesn't read escape characters in the text file, that's solely an ActionScript thing (and, since it's a C derivative, you can use the same escape chars in C: printf("It's the same\nreally!\nAnd\\\Or quite different, you see?"); ).

Anyway,
--Elios