Loading external text issue

Posted on 2003-03-25
Medium Priority
Last Modified: 2010-04-03
Hi all,
I have what I'm sure is an easy one for you.

I'm loading in external text using LoadVars(). No problem initially, but I want to write one function that will populate several dynamic text fields automatically. I have 3 dynamic text fields on the stage named 'main_tab_field', 'second_tab_field' & 'third_tab_field'. My vriables in the text file are named 'main_title', 'second_title', & 'third_title'.

Here is the function I'm working on:

tablist = new Array("main", "second", "third");
for (i=0; i<tablist.length; i++) {
     whichfield = tablist[i] + "_tab_field";
     whichfield.text = this.main_title;

this code returns:
yet the text is not loaded into the fields. If I test by changing "whichfield.text" in line 5 to "main_tab_field.text", then it works fine - the main field gets filled in with the text value. No dice when I try to do it automatically, though.

I'd appreciate you pointing out where I've missed something, thanks in advance.
Question by:kris_mcl
  • 2

Accepted Solution

ocgstyles earned 80 total points
ID: 8207074
you have whichfield equalling a string.  whichfield needs to be an object.  to do that you need to evaluate ( eval() )the string.....  if that makes any sense.  take a look:

tablist = new Array("main", "second", "third");
for (i=0; i<tablist.length; i++) {
    whichfield = eval(tablist[i] + "_tab_field");
    whichfield.text = this.main_title;


Author Comment

ID: 8207115
You're the man, styles!
20 points for you. 17 min for an answer - that's why I love this place!

Expert Comment

ID: 8207295
glad it worked.  thx for the points!

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question