Convert the value of a variable into the name of a variable. sight!

Hi everyone, this is my predicament:

  • I have loaded a TXT file in my flash file (MyTextFile.txt).
  • In the TXT file there are a bunch of variables (Name1, Name2, etc…) each representing the name of a person.
  • Now, I have a dinamic text field (var:_root.MyName) where a name of a person is going to appear.
  • For that I have a lot of buttons (one for each person in the TXT file)
  • So I have this “brilliant” idea
  • I gave to every button an instance name identical as the name of the variable it needs to access in the TXT file. Ej. If I click on button (instance name: Name1), the dynamic text field should showr the name of the person stored in the variable Name1 loaded from the TXT file.
  • For that I wrote this code in the Button:

on (release){
var newName = this._name
_root.TheName = newName;
}

  • And in frame one used this code:

varnombre = _root.TheName;
var lv:LoadVars = new LoadVars();
lv.onLoad = function(obj) {
MyName = varnombre;
}
lv.load(“MyTextFile.txt”);

  • The problem is: Instead of appearing the name of the person in the dynamic text field (var:MyName) what appears is the name of the variable: ej. Name1.

Can someone help me? thank you very muchin advance