Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading from a text file

Status
Not open for further replies.

RandalGroves

Programmer
Apr 17, 2002
7
GB
I was just wondering if someone can tell me how to load text from a .txt file into a flash document.

I have a program and ceratin text will change every day and it will be easier to simply have the program load the text straight from a .txt file every time it is loaded so I only need to change the text in the text file.

I will have about 4 of these boxes all loading text from the .txt file, all different instances (eg BoxA, BoxB, BoxC,...). Each box will only need to get a line from the text file and no more, so the text file will have 4 lines and each line will go in a different box.

Im asumming each box will need an empty text box inside, but I don't know how to get the text from the file and insert into the box.

If anyone can point me in the right direction with this one I will be very thankful to them.
 
You would have to set up 4 different variables in your 4 boxes, and then simply seperate (with the &) and identify these 4 variables in your text file.

In notepad or whatever create test.txt.

&first_variable=This is the first box text!&second_variable=This is the second box text!&third_variable=This is the third box text!&fourth_variable=This is the fourth box text!

No spaces or new lines in the above.

Then from Flash, you simply have to add a frame action:

loadVariablesNum ("test.txt", 0);

The text should appear in your 4 boxes.

After typing all of the above, just realized that although this would work, maybe you're better off using the onClipEvent(data) action, and you should maybe check this:


Regards,
new.gif
 
Thanks,

I was wondering if you could also help me with this :-
I have a movie clip called Questions which is simply a empty text file with variable text.

I then make 4 instances of the movie clip Questions named - QuestionsA, QuestionsB, QuestionsC and QuestionsD. So all these instances have the empty text file with variable text.

How do I load the text from the text file into each one of these instances?

Thanks in advance.
 
Hello RandalGroves!

You can use several methods to do this. You can load the text using a button or load it as frame itself is loaded.

IMHO, loading it upon frameload is best and appears to be very consistant. So, double-click on frame where you placed the MC and add action script to load text file.

Follow these links for step by step on how to:



Hope this helps!

Regards;


josel KNOWLEDGE: Something you can give away enlessly and gain more of it in the process! - Jose Lerebours
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top