PDA

View Full Version : Multiline Dynamic Text


GH33DA
01-01-2003, 01:38 AM
I want to read in multiline text from a text file and display it in a dyamic text box. how?

Also, how would one write multiline text in an actionscript?

boyzdynasty
01-01-2003, 02:00 AM
Originally posted by GH33DA
I want to read in multiline text from a text file and display it in a dyamic text box. how?

Also, how would one write multiline text in an actionscript?

good question about the actionscript thing....I'm not sure there is one but then again I still consider myself as a newbie :rolleyes:

------
The regular way that I know is....

Create a dynamic text box and give it a name in the "var" box that is located in properties window.
Let's say you gave it the name dataFiles

now you will need a file .... can call it data.txt
In the data file you need to set it up like this:
dataFiles = this is the info. i want to display

*Note if you are loading to more than one variable in the movie you want to indicate that in the data file.

Example:
======
dataFiles = this is the info. i want to display&secondVar=this is the other info. i want to this display.

here is the actionscript to load the file

// I made the assumption that the text box is located on the mainTimeLine
loadVariables("data.txt","_root.dataFiles");


Let me know how it turns out.

Good Luck,
-SAm

bembino
01-01-2003, 08:39 AM
This is the complete ActionScript way. Create a txt file that looks something like this and save it as blah.txt.
content=Blah, blah, blah, blah, bladdity vlah blah
Then back in yor Flash movie use the following code to create a textfield and load content into it.
//create multiline textfield with wordwrap
//createTextField(instance name, depth, x, y, width, height);
this.createTextField("myText_txt", 1, 0, 0, 100, 20);
myText_txt.multiline = true;
myText_txt.wordWrap = true;
myText_txt.autoSize = true;

//create LoadVars object to load text file info
myLV = new LoadVars();
myLV.onLoad = function() {
myText_txt.text = this.content;
}
myLV.load("blah.txt");
That's just a very basic example.

boyzdynasty
01-01-2003, 04:12 PM
wow...i didn't know that.

cool. That will come in handy for me since i am tryin' to be more actionScript oriented.


*many thanx*

GH33DA
01-03-2003, 12:49 AM
Thanks guys!

Both ways work. One Question, why is there so much space inbetween my lines?

bembino
01-03-2003, 06:44 AM
I think I remember reading somewhere that it has something to do with the way PCs encode the txt file. When you press ENTER it places both a carriage return and a new line. So you get the double space. I tried different encodings (ANSI, Unicode, and UTF-8) but they all had the double space.

boyzdynasty
01-03-2003, 03:45 PM
what i do is... put everything in one line

which is hard to veiw but it works.

test = kdfjldsjfljsdfl;kjsdfjjdsfljsdfll................. ...........................

eventually...you get to the max column and it will go to the next line for you.

bembino
01-03-2003, 06:24 PM
You could also put a %0A or %0D where you want a line break to be. I think there is another way too, but I'm not sure.

boyzdynasty
01-03-2003, 08:39 PM
hey bembino...i found this site where it gave me syntax to use in the text feild for format...

but i can't find it any more....*sigh*

I wanted to know if you knew of any>......