?
Solved

Loading external text issue

Posted on 2003-03-25
3
Medium Priority
?
144 Views
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";
     trace(whichfield);
     whichfield.text = this.main_title;
}


this code returns:
     main_tab_field
     second_tab_field
     third_tab_field
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.
//km
0
Comment
Question by:kris_mcl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
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");
    trace(whichfield);
    whichfield.text = this.main_title;
}

-styles
0
 

Author Comment

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

Expert Comment

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
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
Course of the Month12 days, 4 hours left to enroll

752 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