View Full Version : how to read .txt files into a text box?
flyrod
01-11-2001, 09:13 PM
can Flash 5 read the contents of a .txt file and parse it into a text box?
not sure if this is the correct terminology, but i want to create a .txt file, say containing financial info, and have it appear in my movie.
the reason: so i can update multiple movies that will read from the .txt file, only having to update the .txt.
thanks. this board is an invaluable resource.
Jesse
01-11-2001, 10:42 PM
Sure, all you have to do is create a text box (field) on your stage (select dymanic text int he text inspector in Flash 5) and set the variable it holds to 'loadedtext' or seomthing.
Then create a text file with the following form:
loadedtext=The String You Wish to Show In Your Text Box
Save this as 'filename.txt' or the like, in the same directory as your .fla file.
Then use loadVariable on the first frames of your movie clip as follows:
loadVariablesNum ("filename.txt", 0);
That will oad the variables fromt he text file into your flash movie on _level0, and they should show up in your text field.
Cheers
Jesse
flyrod
01-12-2001, 01:32 AM
it doesn't work. this is what i have:
loadVariables ("text.txt", 0);
i have the .txt file in the same folder as the .swf but nothing comes up. do i have to point it to the text field or write something in the .txt file o get this to work?
thanks for your help.
flyrod
01-12-2001, 01:51 AM
i got it to work. thanks again for your help.
one other question:
can i format the text in any way, say, to change it's font for different words or color, or maybe even to link some text to a URL?
Jesse
01-12-2001, 05:23 AM
If you have Flash 5 you can check the HTML box and then use HTML code in your text file to format the color and add links. You cannot import images or do much more than change the color though. HTML support is still very basic.
Cheers
Jesse
flyrod
01-12-2001, 02:22 PM
not sure how to format the .html file to have it read in flash. all i get is "Untitled Document", but nothing in the <body> tag.
any suggestions?
Jesse
01-13-2001, 01:53 AM
As far as I know you can't import fully fledge HTML files with BODY and HEAD commands and the like., I've only ever use stuff like COLOR and A HREF . With those I had no problems. Also stuff like table formatting seems not to work. Like I said, it's very basic level support.
Cheers
Jesse
flyrod
01-19-2001, 03:23 PM
hey jesse - thanks for all of your help. i have another question:
i want to be able to have users input info and have that info formatted into xml... i think this is pretty easy, just predefine each text box to equal a certain <tag>..?
but then.... how can i have that xml converted into html or similar web based code so that what they input can be read easily by other users or sent to a database? i guess the database part is done thru the <tags>, but i'm not sure of how to convert xml into html (css or xsl?)
oh yeah! how do i do a mailto: without using getURL?
thanks again for the time you spend on this board helping people less gifted with AS than you.
tah!
FlashGuru
01-20-2001, 12:42 PM
Hi to accomplish this with flash is possible, all you have to do is create your html page inside flash. By creating the correct html tags and placing them in the right order, from which you can then send to a server-side script which in-turn writes the html to a html document!
mailto cannot be done without the getUrl command:
getURL("mailto:flashguru@flashkit.com")
FlashGuru
01-20-2001, 12:43 PM
I dont have time this second to write you the flash script but i will do soon!
Its just a bit of xml
|
vBulletin® v3.8.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.